diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-17 09:52:42 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-04-17 09:52:42 +0000 |
commit | b84ed6e7c85a8a59379aedae5501074fcfc9b161 (patch) | |
tree | 040fcfe3885d053d849b5dc2915d667682589f82 /plugins/Dropbox | |
parent | b9e3d0d154f994e77091e250a412415a2c454140 (diff) |
dropbox: small improvments
git-svn-id: http://svn.miranda-ng.org/main/trunk@12880 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dropbox')
-rw-r--r-- | plugins/Dropbox/src/dropbox.cpp | 4 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox.h | 5 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_events.cpp | 3 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_icons.cpp | 9 | ||||
-rw-r--r-- | plugins/Dropbox/src/dropbox_services.cpp | 41 |
5 files changed, 59 insertions, 3 deletions
diff --git a/plugins/Dropbox/src/dropbox.cpp b/plugins/Dropbox/src/dropbox.cpp index 827b42a45e..7487fab330 100644 --- a/plugins/Dropbox/src/dropbox.cpp +++ b/plugins/Dropbox/src/dropbox.cpp @@ -16,6 +16,10 @@ CDropbox::CDropbox() CreateServiceFunctionObj(MS_DROPBOX_SEND_FILE, SendFileToDropbox, this);
CreateProtoServiceFunction(MODULE, PS_GETCAPS, ProtoGetCaps);
+ CreateProtoServiceFunction(MODULE, PS_GETNAME, ProtoGetName);
+ CreateProtoServiceFunction(MODULE, PS_LOADICON, ProtoLoadIcon);
+ CreateProtoServiceFunction(MODULE, PS_GETSTATUS, ProtoGetStatus);
+ CreateProtoServiceFunctionObj(PS_SETSTATUS, ProtoSetStatus, this);
CreateProtoServiceFunctionObj(PSS_FILEW, ProtoSendFile, this);
CreateProtoServiceFunctionObj(PSS_MESSAGE, ProtoSendMessage, this);
CreateProtoServiceFunctionObj(PSR_MESSAGE, ProtoReceiveMessage, this);
diff --git a/plugins/Dropbox/src/dropbox.h b/plugins/Dropbox/src/dropbox.h index 65fc092e70..bb07d1f921 100644 --- a/plugins/Dropbox/src/dropbox.h +++ b/plugins/Dropbox/src/dropbox.h @@ -70,6 +70,10 @@ private: static HANDLE CreateProtoServiceFunctionObj(const char *szService, MIRANDASERVICEOBJ serviceProc, void *obj);
static INT_PTR ProtoGetCaps(WPARAM wParam, LPARAM lParam);
+ static INT_PTR ProtoGetName(WPARAM wParam, LPARAM lParam);
+ static INT_PTR ProtoLoadIcon(WPARAM wParam, LPARAM lParam);
+ static INT_PTR ProtoGetStatus(WPARAM wParam, LPARAM lParam);
+ static INT_PTR ProtoSetStatus(void *obj, WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoSendFile(void *obj, WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoSendMessage(void *obj, WPARAM wParam, LPARAM lParam);
static INT_PTR ProtoReceiveMessage(void *obj, WPARAM wParam, LPARAM lParam);
@@ -112,6 +116,7 @@ private: // icons
void InitializeIcons();
+ static HICON LoadIconEx(const char *name, bool big);
// menus
void InitializeMenus();
diff --git a/plugins/Dropbox/src/dropbox_events.cpp b/plugins/Dropbox/src/dropbox_events.cpp index 7698d5dc9e..d361f07d28 100644 --- a/plugins/Dropbox/src/dropbox_events.cpp +++ b/plugins/Dropbox/src/dropbox_events.cpp @@ -86,11 +86,10 @@ int CDropbox::OnOptionsInitialized(void *obj, WPARAM wParam, LPARAM) int CDropbox::OnSrmmWindowOpened(void *obj, WPARAM, LPARAM lParam)
{
- CDropbox *instance = (CDropbox*)obj;
-
MessageWindowEventData *ev = (MessageWindowEventData*)lParam;
if (ev->uType == MSG_WINDOW_EVT_OPENING && ev->hContact)
{
+ CDropbox *instance = (CDropbox*)obj;
char *proto = GetContactProto(ev->hContact);
bool isProtoOnline = CallProtoService(proto, PS_GETSTATUS, 0, 0) > ID_STATUS_OFFLINE;
WORD status = db_get_w(ev->hContact, proto, "Status", ID_STATUS_OFFLINE);
diff --git a/plugins/Dropbox/src/dropbox_icons.cpp b/plugins/Dropbox/src/dropbox_icons.cpp index 5684fc9ed4..d3bded41f7 100644 --- a/plugins/Dropbox/src/dropbox_icons.cpp +++ b/plugins/Dropbox/src/dropbox_icons.cpp @@ -30,4 +30,11 @@ void CDropbox::InitializeIcons() sid.ptszDescription = LPGENT("Protocol icon");
sid.iDefaultIndex = -IDI_DROPBOX;
/*HANDLE hIcon = */Skin_AddIcon(&sid);
-}
\ No newline at end of file +}
+
+HICON CDropbox::LoadIconEx(const char *name, bool big)
+{
+ char szSettingName[100];
+ mir_snprintf(szSettingName, SIZEOF(szSettingName), "%s_%s", MODULE, name);
+ return Skin_GetIcon(szSettingName, big);
+}
diff --git a/plugins/Dropbox/src/dropbox_services.cpp b/plugins/Dropbox/src/dropbox_services.cpp index 6842e76989..270b129d50 100644 --- a/plugins/Dropbox/src/dropbox_services.cpp +++ b/plugins/Dropbox/src/dropbox_services.cpp @@ -1,5 +1,7 @@ #include "common.h"
+int g_nStatus = ID_STATUS_OFFLINE;
+
HANDLE CDropbox::CreateProtoServiceFunctionObj(const char *szService, MIRANDASERVICEOBJ serviceProc, void *obj)
{
char str[MAXMODULELABELLENGTH];
@@ -23,6 +25,45 @@ INT_PTR CDropbox::ProtoGetCaps(WPARAM wParam, LPARAM) return 0;
}
+INT_PTR CDropbox::ProtoGetName(WPARAM wParam, LPARAM lParam)
+{
+ if (lParam) {
+ mir_strncpy((char *)lParam, MODULE, wParam);
+ return 0;
+ }
+
+ return 1;
+}
+
+INT_PTR CDropbox::ProtoLoadIcon(WPARAM wParam, LPARAM)
+{
+ return (LOWORD(wParam) == PLI_PROTOCOL) ? (INT_PTR)CopyIcon(LoadIconEx("main", FALSE)) : 0;
+}
+
+INT_PTR CDropbox::ProtoGetStatus(WPARAM, LPARAM)
+{
+ return g_nStatus;
+}
+
+INT_PTR CDropbox::ProtoSetStatus(void *obj, WPARAM wp, LPARAM)
+{
+ CDropbox *instance = (CDropbox*)obj;
+ int nStatus = wp;
+ if ((ID_STATUS_ONLINE == nStatus) || (ID_STATUS_OFFLINE == nStatus)) {
+ int nOldStatus = g_nStatus;
+ if (nStatus != g_nStatus) {
+ g_nStatus = nStatus;
+
+ MCONTACT hContact = instance->GetDefaultContact();
+ db_set_w(hContact, MODULE, "Status", nStatus);
+
+ ProtoBroadcastAck(MODULE, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)nOldStatus, g_nStatus);
+ }
+ }
+
+ return 0;
+}
+
INT_PTR CDropbox::ProtoSendFile(void *obj, WPARAM, LPARAM lParam)
{
CDropbox *instance = (CDropbox*)obj;
|