You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

notification.mm 1.2 kB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include "notification.h"
  2. #include "notificationimpl.h"
  3. #include <QDebug>
  4. #include "../mainwindow.h"
  5. static NotificationImpl* impl = [[NotificationImpl alloc] init];
  6. static void clickCallback(void* arg, NSString* fellowIp)
  7. {
  8. MainWindow* mainWnd = (MainWindow*)arg;
  9. const char* ip = [fellowIp UTF8String];
  10. mainWnd->onNotifyClicked(ip);
  11. }
  12. static void replyCallback(void* arg, long notifyId, NSString* fellowIp, NSString* str)
  13. {
  14. const char* reply = [str UTF8String];
  15. const char* ip = [fellowIp UTF8String];
  16. MainWindow* mainWnd = (MainWindow*)arg;
  17. mainWnd->onNotifyReplied(notifyId, ip, reply);
  18. }
  19. Notification::Notification()
  20. {
  21. }
  22. int Notification::show(const QString &title, const QString &content, const QString& fellowIp)
  23. {
  24. NSString* objcTitle = title.toNSString();
  25. NSString* objcMessage = content.toNSString();
  26. return [impl show: objcTitle message: objcMessage extra: fellowIp.toNSString()];
  27. }
  28. void Notification::hideAll()
  29. {
  30. [impl hideAll];
  31. }
  32. void Notification::setMainWnd(MainWindow *mainWnd)
  33. {
  34. impl->clickCallback = clickCallback;
  35. impl->replyCallback = replyCallback;
  36. impl->callbackArg = mainWnd;
  37. }

mac下的“飞秋”大多数只是飞鸽传书协议,而且未发现令人满意的开源项目,所以基于c++与qt实现了基础的飞秋协议。

Contributors (1)