FACT++  1.0
string SkypeClient::SendDBusMessage ( const string &  cmd,
bool  display = true 
)
inlineprivate

Definition at line 197 of file skypeclient.cc.

References display, and Error().

198  {
199  DBusMessage *send = GetDBusMessage(cmd);
200  if (!send)
201  return "";
202 
203  DBusError error;
204  dbus_error_init(&error);
205 
206  // Send the message and wait for reply
207  if (display)
208  Info("TX: "+cmd);
209  DBusMessage *reply=
210  dbus_connection_send_with_reply_and_block(fBus, send,
211  -1,//DBUS_TIMEOUT_USE_DEFAULT,
212  &error);
213  /*
214  DBusPendingCall *pending = 0;
215  if (!dbus_connection_send_with_reply (fBus, send,
216  &pending, DBUS_TIMEOUT_USE_DEFAULT))
217  return "";
218 
219  if (!pending)
220  return "";
221 
222  bool = dbus_pending_call_get_completed(pending);
223  //dbus_pending_call_block(pending);
224  DBusMessage *reply = dbus_pending_call_steal_reply(pending);
225  dbus_pending_call_unref(pending);
226  */
227 
228  if (!reply)
229  {
230  Error("dbus_connection_send_with_reply_and_block: "+string(error.message));
231  dbus_error_free(&error);
232  return "";
233  }
234 
235  // Get Skype's reply string
236  const char *ack = 0;
237  dbus_message_get_args(reply, 0, DBUS_TYPE_STRING, &ack, DBUS_TYPE_INVALID);
238 
239  if (display)
240  Info("RX: "+string(ack));
241 
242  const string rc = ack;
243 
244  // Show no interest in the previously created messages.
245  // DBus will delete a message if reference count drops to zero.
246  dbus_message_unref(send);
247  dbus_message_unref(reply);
248 
249  return rc;
250  }
DBusMessage * GetDBusMessage(const string &cmd)
Definition: skypeclient.cc:252
Display * display
Definition: did.h:37
int Error(const std::string &str)
Definition: MessageImp.h:49
DBusConnection * fBus
Definition: skypeclient.cc:26
int Info(const std::string &str)
Definition: MessageImp.h:47

+ Here is the call graph for this function: