summaryrefslogtreecommitdiffstats
path: root/accessible/windows/ia2/ia2AccessibleApplication.cpp
blob: 7844e970748a7e09aeab941738304ba130fc8511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
 */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "ia2AccessibleApplication.h"

#include "AccessibleApplication_i.c"
#include "ApplicationAccessibleWrap.h"

using namespace mozilla;
using namespace mozilla::a11y;

ApplicationAccessible* ia2AccessibleApplication::AppAcc() {
  return static_cast<ApplicationAccessible*>(LocalAcc());
}

////////////////////////////////////////////////////////////////////////////////
// IUnknown

IMPL_IUNKNOWN_QUERY_HEAD(ia2AccessibleApplication)
IMPL_IUNKNOWN_QUERY_IFACE(IAccessibleApplication)
IMPL_IUNKNOWN_QUERY_TAIL_INHERITED(MsaaAccessible)

////////////////////////////////////////////////////////////////////////////////
// IAccessibleApplication

STDMETHODIMP
ia2AccessibleApplication::get_appName(BSTR* aName) {
  if (!aName) return E_INVALIDARG;

  *aName = nullptr;

  ApplicationAccessible* appAcc = AppAcc();
  if (!appAcc) return CO_E_OBJNOTCONNECTED;

  nsAutoString name;
  appAcc->AppName(name);
  if (name.IsEmpty()) return S_FALSE;

  *aName = ::SysAllocStringLen(name.get(), name.Length());
  return *aName ? S_OK : E_OUTOFMEMORY;
}

STDMETHODIMP
ia2AccessibleApplication::get_appVersion(BSTR* aVersion) {
  if (!aVersion) return E_INVALIDARG;

  *aVersion = nullptr;

  ApplicationAccessible* appAcc = AppAcc();
  if (!appAcc) return CO_E_OBJNOTCONNECTED;

  nsAutoString version;
  appAcc->AppVersion(version);
  if (version.IsEmpty()) return S_FALSE;

  *aVersion = ::SysAllocStringLen(version.get(), version.Length());
  return *aVersion ? S_OK : E_OUTOFMEMORY;
}

STDMETHODIMP
ia2AccessibleApplication::get_toolkitName(BSTR* aName) {
  if (!aName) return E_INVALIDARG;

  ApplicationAccessible* appAcc = AppAcc();
  if (!appAcc) return CO_E_OBJNOTCONNECTED;

  nsAutoString name;
  appAcc->PlatformName(name);
  if (name.IsEmpty()) return S_FALSE;

  *aName = ::SysAllocStringLen(name.get(), name.Length());
  return *aName ? S_OK : E_OUTOFMEMORY;
}

STDMETHODIMP
ia2AccessibleApplication::get_toolkitVersion(BSTR* aVersion) {
  if (!aVersion) return E_INVALIDARG;

  *aVersion = nullptr;

  ApplicationAccessible* appAcc = AppAcc();
  if (!appAcc) return CO_E_OBJNOTCONNECTED;

  nsAutoString version;
  appAcc->PlatformVersion(version);
  if (version.IsEmpty()) return S_FALSE;

  *aVersion = ::SysAllocStringLen(version.get(), version.Length());
  return *aVersion ? S_OK : E_OUTOFMEMORY;
}