tdebluez
libtdeobex/interfaces/agent1Interface.cpp
Go to the documentation of this file.
1 // File autogenerated
2 
3 // declaration include
4 #include "agent1Interface.h"
5 
6 // TQt includes
7 #include <tqdom.h>
8 #include <tqstring.h>
9 
10 // TQt D-Bus includes
11 #include <tqdbuserror.h>
12 #include <tqdbusmessage.h>
13 #include <tqdbusobjectpath.h>
14 
15 
16 namespace org
17 {
18 namespace bluez
19 {
20 namespace obex
21 {
22 
23 void Agent1Interface::buildIntrospectionData(TQDomElement& interfaceElement)
24 {
25  interfaceElement.setAttribute("name", "org.bluez.obex.Agent1");
26 
27  TQDomDocument document = interfaceElement.ownerDocument();
28  TQDomElement methodElement = document.createElement("method");
29  TQDomElement asyncAnnotationElement = document.createElement("annotation");
30  asyncAnnotationElement.setAttribute("name", "org.freedesktop.DBus.GLib.Async");
31  asyncAnnotationElement.setAttribute("value", "true");
32  methodElement.appendChild(asyncAnnotationElement);
33  methodElement.setAttribute("name", "Release");
34 
35  interfaceElement.appendChild(methodElement);
36 
37  methodElement = document.createElement("method");
38  asyncAnnotationElement = document.createElement("annotation");
39  asyncAnnotationElement.setAttribute("name", "org.freedesktop.DBus.GLib.Async");
40  asyncAnnotationElement.setAttribute("value", "true");
41  methodElement.appendChild(asyncAnnotationElement);
42  methodElement.setAttribute("name", "AuthorizePush");
43 
44  TQDomElement argumentElement = document.createElement("arg");
45  argumentElement.setAttribute("name", "transfer");
46  argumentElement.setAttribute("type", "o");
47  argumentElement.setAttribute("direction", "in");
48  methodElement.appendChild(argumentElement);
49 
50  argumentElement = document.createElement("arg");
51  argumentElement.setAttribute("name", "filepath");
52  argumentElement.setAttribute("type", "s");
53  argumentElement.setAttribute("direction", "out");
54  methodElement.appendChild(argumentElement);
55 
56  interfaceElement.appendChild(methodElement);
57 
58  methodElement = document.createElement("method");
59  asyncAnnotationElement = document.createElement("annotation");
60  asyncAnnotationElement.setAttribute("name", "org.freedesktop.DBus.GLib.Async");
61  asyncAnnotationElement.setAttribute("value", "true");
62  methodElement.appendChild(asyncAnnotationElement);
63  methodElement.setAttribute("name", "Cancel");
64 
65  interfaceElement.appendChild(methodElement);
66 }
67 
69 
70 {
71  TQMap<int, TQT_DBusMessage>::iterator findIt = m_asyncCalls.find(asyncCallId);
72  if (findIt == m_asyncCalls.end()) return;
73 
74  TQT_DBusMessage call = findIt.data();
75  m_asyncCalls.erase(findIt);
76 
77  TQT_DBusMessage reply = TQT_DBusMessage::methodReply(call);
78 
79  handleMethodReply(reply);
80 }
81 
82 void Agent1Interface::ReleaseAsyncError(int asyncCallId, const TQT_DBusError& error)
83 {
84  TQMap<int, TQT_DBusMessage>::iterator findIt = m_asyncCalls.find(asyncCallId);
85  if (findIt == m_asyncCalls.end()) return;
86 
87  TQT_DBusMessage call = findIt.data();
88  m_asyncCalls.erase(findIt);
89 
90  TQT_DBusMessage reply = TQT_DBusMessage::methodError(call, error);
91  handleMethodReply(reply);
92 }
93 
94 void Agent1Interface::AuthorizePushAsyncReply(int asyncCallId, const TQString& filepath)
95 
96 {
97  TQMap<int, TQT_DBusMessage>::iterator findIt = m_asyncCalls.find(asyncCallId);
98  if (findIt == m_asyncCalls.end()) return;
99 
100  TQT_DBusMessage call = findIt.data();
101  m_asyncCalls.erase(findIt);
102 
103  TQT_DBusMessage reply = TQT_DBusMessage::methodReply(call);
104  reply << TQT_DBusData::fromString(filepath);
105 
106  handleMethodReply(reply);
107 }
108 
109 void Agent1Interface::AuthorizePushAsyncError(int asyncCallId, const TQT_DBusError& error)
110 {
111  TQMap<int, TQT_DBusMessage>::iterator findIt = m_asyncCalls.find(asyncCallId);
112  if (findIt == m_asyncCalls.end()) return;
113 
114  TQT_DBusMessage call = findIt.data();
115  m_asyncCalls.erase(findIt);
116 
117  TQT_DBusMessage reply = TQT_DBusMessage::methodError(call, error);
118  handleMethodReply(reply);
119 }
120 
122 
123 {
124  TQMap<int, TQT_DBusMessage>::iterator findIt = m_asyncCalls.find(asyncCallId);
125  if (findIt == m_asyncCalls.end()) return;
126 
127  TQT_DBusMessage call = findIt.data();
128  m_asyncCalls.erase(findIt);
129 
130  TQT_DBusMessage reply = TQT_DBusMessage::methodReply(call);
131 
132  handleMethodReply(reply);
133 }
134 
135 void Agent1Interface::CancelAsyncError(int asyncCallId, const TQT_DBusError& error)
136 {
137  TQMap<int, TQT_DBusMessage>::iterator findIt = m_asyncCalls.find(asyncCallId);
138  if (findIt == m_asyncCalls.end()) return;
139 
140  TQT_DBusMessage call = findIt.data();
141  m_asyncCalls.erase(findIt);
142 
143  TQT_DBusMessage reply = TQT_DBusMessage::methodError(call, error);
144  handleMethodReply(reply);
145 }
146 
147 void Agent1Interface::callReleaseAsync(const TQT_DBusMessage& message)
148 {
149 
150  int _asyncCallId = 0;
151  while (m_asyncCalls.find(_asyncCallId) != m_asyncCalls.end())
152  {
153  ++_asyncCallId;
154  }
155  m_asyncCalls.insert(_asyncCallId, message);
156 
157  ReleaseAsync(_asyncCallId);
158 
159  return;
160 }
161 
162 void Agent1Interface::callAuthorizePushAsync(const TQT_DBusMessage& message)
163 {
164  TQT_DBusObjectPath _transfer = message[0].toObjectPath();
165 
166  int _asyncCallId = 0;
167  while (m_asyncCalls.find(_asyncCallId) != m_asyncCalls.end())
168  {
169  ++_asyncCallId;
170  }
171  m_asyncCalls.insert(_asyncCallId, message);
172 
173  AuthorizePushAsync(_asyncCallId, _transfer);
174 
175  return;
176 }
177 
178 void Agent1Interface::callCancelAsync(const TQT_DBusMessage& message)
179 {
180 
181  int _asyncCallId = 0;
182  while (m_asyncCalls.find(_asyncCallId) != m_asyncCalls.end())
183  {
184  ++_asyncCallId;
185  }
186  m_asyncCalls.insert(_asyncCallId, message);
187 
188  CancelAsync(_asyncCallId);
189 
190  return;
191 }
192 
193 bool Agent1Interface::handleMethodCall(const TQT_DBusMessage& message)
194 {
195  if (message.interface() != "org.bluez.obex.Agent1") return false;
196 
197  if (message.member() == "Release")
198  {
199  callReleaseAsync(message);
200 
201  return true;
202  }
203 
204  if (message.member() == "AuthorizePush")
205  {
206  callAuthorizePushAsync(message);
207 
208  return true;
209  }
210 
211  if (message.member() == "Cancel")
212  {
213  callCancelAsync(message);
214 
215  return true;
216  }
217 
218  return false;
219 }
220 
221 }; // namespace obex
222 
223 }; // namespace bluez
224 
225 }; // namespace org
226 
227 // End of File
228 
void callReleaseAsync(const TQT_DBusMessage &message)
virtual void ReleaseAsyncError(int asyncCallId, const TQT_DBusError &error)
virtual void CancelAsyncError(int asyncCallId, const TQT_DBusError &error)
virtual void handleMethodReply(const TQT_DBusMessage &reply)=0
virtual void CancelAsync(int asyncCallId)=0
virtual void AuthorizePushAsyncReply(int asyncCallId, const TQString &filepath)
void callAuthorizePushAsync(const TQT_DBusMessage &message)
void callCancelAsync(const TQT_DBusMessage &message)
virtual void AuthorizePushAsync(int asyncCallId, const TQT_DBusObjectPath &transfer)=0
virtual void ReleaseAsync(int asyncCallId)=0
static void buildIntrospectionData(TQDomElement &interfaceElement)
virtual void AuthorizePushAsyncError(int asyncCallId, const TQT_DBusError &error)
virtual bool handleMethodCall(const TQT_DBusMessage &message)