diff options
author | George Hazan <george.hazan@gmail.com> | 2015-03-31 11:55:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-03-31 11:55:37 +0000 |
commit | bebfb51465b364d5673a3f555655213dbff0b2c6 (patch) | |
tree | 736767fcbfa242e05c82ee6cb5038c4ee4283696 /plugins/Non-IM Contact/src/services.cpp | |
parent | a9feca3461062a266adf9e240a2f436ca27b4ffb (diff) |
Non-IM Contact:
- fix for a crash on exit;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@12573 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 | 92 |
1 files changed, 44 insertions, 48 deletions
diff --git a/plugins/Non-IM Contact/src/services.cpp b/plugins/Non-IM Contact/src/services.cpp index a0a3810397..7ef9b0c760 100644 --- a/plugins/Non-IM Contact/src/services.cpp +++ b/plugins/Non-IM Contact/src/services.cpp @@ -1,54 +1,47 @@ #include "commonheaders.h"
//=======================================================
-//db_get_static
+// db_get_static
//=======================================================
-int db_get_static(MCONTACT hContact, const char *szModule, const char *szSetting, char *value)
+
+int db_get_static(MCONTACT hContact, const char *szModule, const char *szSetting, char *value, size_t length)
{
- DBVARIANT dbv;
- if (!db_get(hContact, szModule, szSetting, &dbv))
- {
- strcpy(value, dbv.pszVal);
- db_free(&dbv);
- return 1;
- }
- else
- {
- db_free(&dbv);
+ ptrA str(db_get_sa(hContact, szModule, szSetting));
+ if (str == NULL)
return 0;
- }
-
- return 0;
+
+ strncpy_s(value, length, str, _TRUNCATE);
+ return 1;
}
//=======================================================
-//GetCaps
+// GetCaps
//=======================================================
-INT_PTR GetLCCaps(WPARAM wParam,LPARAM lParam)
+INT_PTR GetLCCaps(WPARAM wParam, LPARAM lParam)
{
- if (wParam==PFLAGNUM_1)
+ 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)
+ 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
+// GetName
//=======================================================
-INT_PTR GetLCName(WPARAM wParam,LPARAM lParam)
+INT_PTR GetLCName(WPARAM wParam, LPARAM lParam)
{
mir_strncpy((char*)lParam, MODNAME, wParam);
return 0;
}
//=======================================================
-//BPLoadIcon
+// BPLoadIcon
//=======================================================
-INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam)
+INT_PTR LoadLCIcon(WPARAM wParam, LPARAM lParam)
{
if (LOWORD(wParam) == PLI_PROTOCOL) {
if (wParam & PLIF_ICOLIBHANDLE)
@@ -63,62 +56,65 @@ INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam) return (INT_PTR)hIcon2;
}
- return NULL;
+ return NULL;
}
//=======================================================
-//SetFStatus
+// SetFStatus
//=======================================================
-int SetLCStatus(WPARAM wParam,LPARAM lParam)
-{
+
+int SetLCStatus(WPARAM wParam, LPARAM lParam)
+{
int 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);
-
- for (MCONTACT hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact,MODNAME)) {
+ 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);
+
+ for (MCONTACT hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, 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));
+ 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));
+ 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)db_get_w(hContact, MODNAME, "Icon",ID_STATUS_ONLINE));
+ 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)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));
+ 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));
+ 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;
}
}
- ProtoBroadcastAck(MODNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
- return 0;
-}
+ ProtoBroadcastAck(MODNAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam);
+ return 0;
+}
//=======================================================
-//GetStatus
+// GetStatus
//=======================================================
-INT_PTR GetLCStatus(WPARAM wParam,LPARAM lParam)
+
+INT_PTR GetLCStatus(WPARAM wParam, LPARAM lParam)
{
if ((LCStatus >= ID_STATUS_ONLINE) && (LCStatus <= ID_STATUS_OUTTOLUNCH))
return LCStatus;
|