diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-02 15:39:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-02 15:39:37 +0000 |
commit | bba1ccccb6072b6e12ede32d4e8e6a28ede32c5c (patch) | |
tree | 5e35e904856f67a54762ff16a0e3d0a8f7928d57 /plugins/Non-IM Contact/src/services.cpp | |
parent | 6270be1be1979c0ad41ea506200431bcfc79360c (diff) |
first version of Non-IM Contact that could be compiled
git-svn-id: http://svn.miranda-ng.org/main/trunk@4287 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Non-IM Contact/src/services.cpp')
-rw-r--r-- | plugins/Non-IM Contact/src/services.cpp | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/plugins/Non-IM Contact/src/services.cpp b/plugins/Non-IM Contact/src/services.cpp new file mode 100644 index 0000000000..1e547fb80c --- /dev/null +++ b/plugins/Non-IM Contact/src/services.cpp @@ -0,0 +1,127 @@ +#include "commonheaders.h"
+
+//=======================================================
+//db_get_static
+//=======================================================
+int db_get_static(HANDLE hContact, const char *szModule, const char *szSetting, char *value)
+{
+ DBVARIANT dbv;
+ if (!DBGetContactSetting(hContact, szModule, szSetting, &dbv))
+ {
+ strcpy(value, dbv.pszVal);
+ db_free(&dbv);
+ return 1;
+ }
+ else
+ {
+ db_free(&dbv);
+ return 0;
+ }
+
+ return 0;
+}
+
+//=======================================================
+//GetCaps
+//=======================================================
+
+INT_PTR GetLCCaps(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam==PFLAGNUM_1)
+ return 0;
+ if (wParam==PFLAGNUM_2)
+ return PF2_ONLINE|PF2_LONGAWAY|PF2_SHORTAWAY|PF2_LIGHTDND|PF2_HEAVYDND|PF2_FREECHAT|PF2_INVISIBLE|PF2_OUTTOLUNCH|PF2_ONTHEPHONE; // add the possible statuses here.
+ if (wParam==PFLAGNUM_3)
+ return 0;
+ return 0;
+}
+
+//=======================================================
+//GetName
+//=======================================================
+INT_PTR GetLCName(WPARAM wParam,LPARAM lParam)
+{
+ lstrcpynA((char*)lParam, MODNAME, wParam);
+ return 0;
+}
+
+//=======================================================
+//BPLoadIcon
+//=======================================================
+INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam)
+{
+ UINT id;
+
+ switch(wParam & 0xFFFF) {
+ case PLI_PROTOCOL: id=IDI_MAIN; break; // IDI_MAIN is the main icon for the protocol
+ default: return (int)(HICON)NULL;
+ }
+ return (int)LoadImage(hInst,MAKEINTRESOURCE(id),IMAGE_ICON,GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON),GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON),0);
+}
+
+//=======================================================
+//SetFStatus
+//=======================================================
+int SetLCStatus(WPARAM wParam,LPARAM lParam)
+{
+ int oldStatus;
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ const char* szProto = (const char*)lParam;
+ if (szProto && strcmp(szProto, MODNAME)) return 0; // not nimc so ignore anyway...
+ else if (!szProto && db_get_b(NULL, MODNAME, "IgnoreGlobalStatusChange",0)) return 0; // global change and being ignored
+ else {
+ oldStatus = LCStatus;
+ LCStatus = wParam;
+ db_set_w(NULL, MODNAME, "Status", (WORD)wParam);
+ db_set_w(NULL, MODNAME, "timerCount",0);
+ if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !db_get_b(NULL, MODNAME, "AwayAsStatus", 0)) || !db_get_w(NULL, MODNAME, "Timer",1)) killTimer();
+ else if (db_get_w(NULL, MODNAME, "Timer",1))
+ startTimer(TIMER);
+ while (hContact) {
+ char* proto = GetContactProto(hContact);
+ if (proto && !strcmp(proto, MODNAME)) {
+ if (LCStatus != ID_STATUS_OFFLINE) replaceAllStrings(hContact);
+ switch (LCStatus) {
+ case ID_STATUS_OFFLINE:
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) && !db_get_b(hContact, MODNAME, "VisibleUnlessOffline",1))
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ else
+ db_set_w(hContact,MODNAME, "Status", ID_STATUS_OFFLINE);
+ break;
+ case ID_STATUS_ONLINE:
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ break;
+ case ID_STATUS_AWAY:
+ if (db_get_b(NULL, MODNAME, "AwayAsStatus", 0) && (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || (db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE)==ID_STATUS_AWAY)) )
+ db_set_w(hContact,MODNAME, "Status",(WORD)(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ else if (!db_get_b(NULL, MODNAME, "AwayAsStatus", 0))
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ else
+ db_set_w(hContact,MODNAME, "Status", ID_STATUS_OFFLINE);
+ break;
+ default:
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || LCStatus == db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE))
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ break;
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+ ProtoBroadcastAck(MODNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
+ }
+ return 0;
+}
+
+
+
+//=======================================================
+//GetStatus
+//=======================================================
+INT_PTR GetLCStatus(WPARAM wParam,LPARAM lParam)
+{
+ if ((LCStatus >= ID_STATUS_ONLINE) && (LCStatus <= ID_STATUS_OUTTOLUNCH))
+ return LCStatus;
+ else
+ return ID_STATUS_OFFLINE;
+}
+
|