diff --git a/protocols/purple/Makefile b/protocols/purple/Makefile index 6100cba..08b1485 100644 --- a/protocols/purple/Makefile +++ b/protocols/purple/Makefile @@ -33,6 +33,7 @@ APP_MIME_SIG = application/x-vnd.caya.purple # Also note that spaces in folder names do not work well with this Makefile. SRCS = \ protocols/purple/PurpleApp.cpp \ + protocols/purple/PurpleDialog.cpp \ protocols/purple/PurpleProtocol.cpp \ # Specify the resource definition files to use. Full or relative paths can be diff --git a/protocols/purple/PurpleApp.cpp b/protocols/purple/PurpleApp.cpp index fc5a9a3..3d177b5 100644 --- a/protocols/purple/PurpleApp.cpp +++ b/protocols/purple/PurpleApp.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -916,11 +917,30 @@ static PurpleRequestUiOps _ui_op_request = }; +static PurpleNotifyUiOps _ui_op_notify = +{ + ui_op_notify_message, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL +}; + + void init_ui_ops() { purple_eventloop_set_ui_ops(&_ui_op_eventloops); purple_request_set_ui_ops(&_ui_op_request); + purple_notify_set_ui_ops(&_ui_op_notify); } @@ -1275,6 +1295,25 @@ ui_op_request_action_with_icon(const char* title, const char* primary, } +static void* +ui_op_notify_message(PurpleNotifyMsgType type, const char* title, + const char* primary, const char* secondary) +{ + BString text = primary; + text << "\n" << secondary; + + BAlert* alert = new BAlert(title, text.String(), "OK"); + + if (type == PURPLE_NOTIFY_MSG_WARNING) + alert->SetType(B_WARNING_ALERT); + else if (type == PURPLE_NOTIFY_MSG_ERROR) + alert->SetType(B_STOP_ALERT); + + alert->Go(NULL); + return NULL; +} + + bool is_own_user(PurpleAccount* account, const char* name) { diff --git a/protocols/purple/PurpleApp.h b/protocols/purple/PurpleApp.h index a1a30e8..8b471b0 100644 --- a/protocols/purple/PurpleApp.h +++ b/protocols/purple/PurpleApp.h @@ -200,6 +200,11 @@ private: void* user_data, size_t action_count, va_list actions); + // Notify ui ops + static void* ui_op_notify_message(PurpleNotifyMsgType type, + const char* title, const char* primary, + const char* secondary); + // Util bool is_own_user(PurpleAccount* account, const char* name); diff --git a/protocols/purple/PurpleDialog.cpp b/protocols/purple/PurpleDialog.cpp index 66fff84..43a694f 100644 --- a/protocols/purple/PurpleDialog.cpp +++ b/protocols/purple/PurpleDialog.cpp @@ -38,8 +38,8 @@ PurpleDialog::MessageReceived(BMessage* msg) int32 id; if (msg->FindInt32("index", &id) != B_OK) break; - PurpleRequestActionCb cb = fActions.ItemAt(0)->callback.action; - cb(fUserData, fActions.ItemAt(0)->index); + PurpleRequestActionCb cb = fActions.ItemAt(id)->callback.action; + cb(fUserData, fActions.ItemAt(id)->index); Quit(); break; } diff --git a/protocols/purple/PurpleDialog.h b/protocols/purple/PurpleDialog.h index 352d946..c98dec5 100644 --- a/protocols/purple/PurpleDialog.h +++ b/protocols/purple/PurpleDialog.h @@ -13,7 +13,6 @@ const uint32 ACTION_BUTTON = 'PDab'; - struct RequestAction { BString name;