PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/qutim-0.3.1/protocols/quetzal/src/quetzalnotify.cpp

#
C++ | 148 lines | 111 code | 13 blank | 24 comment | 2 complexity | 651bf775378246cc92399a3f1f39c5be MD5 | raw file
Possible License(s): CC-BY-SA-4.0, GPL-3.0, LGPL-2.1, GPL-2.0
  1. /****************************************************************************
  2. **
  3. ** qutIM - instant messenger
  4. **
  5. ** Copyright Š 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
  6. **
  7. *****************************************************************************
  8. **
  9. ** $QUTIM_BEGIN_LICENSE$
  10. ** This program is free software: you can redistribute it and/or modify
  11. ** it under the terms of the GNU General Public License as published by
  12. ** the Free Software Foundation, either version 3 of the License, or
  13. ** (at your option) any later version.
  14. **
  15. ** This program is distributed in the hope that it will be useful,
  16. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. ** See the GNU General Public License for more details.
  19. **
  20. ** You should have received a copy of the GNU General Public License
  21. ** along with this program. If not, see http://www.gnu.org/licenses/.
  22. ** $QUTIM_END_LICENSE$
  23. **
  24. ****************************************************************************/
  25. #include "quetzalnotify.h"
  26. #include <qutim/notification.h>
  27. #include <QDesktopServices>
  28. #include <QUrl>
  29. #include <QStringList>
  30. #include <QDebug>
  31. using namespace qutim_sdk_0_3;
  32. void *quetzal_notify_message(PurpleNotifyMsgType type, const char *title,
  33. const char *primary, const char *secondary)
  34. {
  35. Q_UNUSED(type);
  36. QString text = primary;
  37. if (secondary && *secondary) {
  38. text += QLatin1Char('\n');
  39. text += primary;
  40. }
  41. NotificationRequest request;
  42. request.setText(text);
  43. request.setTitle(title);
  44. request.send();
  45. return NULL;
  46. }
  47. void *quetzal_notify_email(PurpleConnection *gc,
  48. const char *subject, const char *from,
  49. const char *to, const char *url)
  50. {
  51. Q_UNUSED(gc);
  52. Q_UNUSED(subject);
  53. Q_UNUSED(from);
  54. Q_UNUSED(to);
  55. Q_UNUSED(url);
  56. return NULL;
  57. }
  58. void *quetzal_notify_emails(PurpleConnection *gc,
  59. size_t count, gboolean detailed,
  60. const char **subjects, const char **froms,
  61. const char **tos, const char **urls)
  62. {
  63. Q_UNUSED(gc);
  64. Q_UNUSED(count);
  65. Q_UNUSED(detailed);
  66. Q_UNUSED(subjects);
  67. Q_UNUSED(froms);
  68. Q_UNUSED(tos);
  69. Q_UNUSED(urls);
  70. return NULL;
  71. }
  72. void *quetzal_notify_formatted(const char *title, const char *primary,
  73. const char *secondary, const char *text)
  74. {
  75. QStringList lines = (QStringList() << primary << secondary << text);
  76. lines.removeAll(QString());
  77. NotificationRequest request;
  78. request.setText(lines.join(QLatin1String("\n")));
  79. request.setTitle(QString::fromUtf8(title));
  80. request.send();
  81. return NULL;
  82. }
  83. void *quetzal_notify_searchresults(PurpleConnection *gc, const char *title,
  84. const char *primary, const char *secondary,
  85. PurpleNotifySearchResults *results, gpointer user_data)
  86. {
  87. Q_UNUSED(gc);
  88. Q_UNUSED(title);
  89. Q_UNUSED(primary);
  90. Q_UNUSED(secondary);
  91. Q_UNUSED(results);
  92. Q_UNUSED(user_data);
  93. return NULL;
  94. }
  95. void quetzal_notify_searchresults_new_rows(PurpleConnection *gc,
  96. PurpleNotifySearchResults *results,
  97. void *data)
  98. {
  99. Q_UNUSED(gc);
  100. Q_UNUSED(results);
  101. Q_UNUSED(data);
  102. }
  103. void *quetzal_notify_userinfo(PurpleConnection *gc, const char *who,
  104. PurpleNotifyUserInfo *user_info)
  105. {
  106. Q_UNUSED(gc);
  107. Q_UNUSED(who);
  108. Q_UNUSED(user_info);
  109. return NULL;
  110. }
  111. void *quetzal_notify_uri(const char *uri)
  112. {
  113. QDesktopServices::openUrl(QUrl::fromUserInput(uri));
  114. return NULL;
  115. }
  116. void quetzal_close_notify(PurpleNotifyType type, void *ui_handle)
  117. {
  118. Q_UNUSED(type);
  119. Q_UNUSED(ui_handle);
  120. }
  121. PurpleNotifyUiOps quetzal_notify_uiops = {
  122. quetzal_notify_message,
  123. quetzal_notify_email,
  124. quetzal_notify_emails,
  125. quetzal_notify_formatted,
  126. quetzal_notify_searchresults,
  127. quetzal_notify_searchresults_new_rows,
  128. quetzal_notify_userinfo,
  129. quetzal_notify_uri,
  130. quetzal_close_notify,
  131. NULL,
  132. NULL,
  133. NULL,
  134. NULL
  135. };