summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-03-31 11:55:37 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-03-31 11:55:37 +0000
commitbebfb51465b364d5673a3f555655213dbff0b2c6 (patch)
tree736767fcbfa242e05c82ee6cb5038c4ee4283696
parenta9feca3461062a266adf9e240a2f436ca27b4ffb (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
-rw-r--r--plugins/Non-IM Contact/src/Version.h12
-rw-r--r--plugins/Non-IM Contact/src/commonheaders.h3
-rw-r--r--plugins/Non-IM Contact/src/contactinfo.cpp308
-rw-r--r--plugins/Non-IM Contact/src/dialog.cpp158
-rw-r--r--plugins/Non-IM Contact/src/files.cpp261
-rw-r--r--plugins/Non-IM Contact/src/http.cpp52
-rw-r--r--plugins/Non-IM Contact/src/main.cpp26
-rw-r--r--plugins/Non-IM Contact/src/namereplacing.cpp255
-rw-r--r--plugins/Non-IM Contact/src/services.cpp92
-rw-r--r--plugins/Non-IM Contact/src/timer.cpp21
10 files changed, 561 insertions, 627 deletions
diff --git a/plugins/Non-IM Contact/src/Version.h b/plugins/Non-IM Contact/src/Version.h
index 18a37d91bb..7bf09fc022 100644
--- a/plugins/Non-IM Contact/src/Version.h
+++ b/plugins/Non-IM Contact/src/Version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 6
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 6
#define __RELEASE_NUM 0
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
#define __PLUGIN_NAME "Non-IM Contact"
#define __FILENAME "NimContact.dll"
-#define __DESCRIPTION "Non-IM Contact allows you to add 'contacts' that can act as shortcuts to other programs, or links to web pages.\r\nThe contacts name can be read from a text file (includes any ASCII file).\r\nThis plugin is a combination of Favorites and Text Reader plugins both made by me)"
+#define __DESCRIPTION "Non-IM Contact allows you to add 'contacts' that can act as shortcuts to other programs, or links to web pages.\r\nThe contacts name can be read from a text file (includes any ASCII file).\r\nThis plugin is a combination of Favorites and Text Reader plugins both made by me)"
#define __AUTHOR "Jonathan Gordon"
#define __AUTHOREMAIL "ICQ 98791178, MSN jonnog@hotmail.com"
-#define __AUTHORWEB "http://miranda-ng.org/p/NimContact/"
-#define __COPYRIGHT "© 2003-2004 Jonathan Gordon, jdgordy@gmail.com"
+#define __AUTHORWEB "http://miranda-ng.org/p/NimContact/"
+#define __COPYRIGHT "© 2003-2004 Jonathan Gordon, jdgordy@gmail.com"
diff --git a/plugins/Non-IM Contact/src/commonheaders.h b/plugins/Non-IM Contact/src/commonheaders.h
index d7205aa895..08c45935e2 100644
--- a/plugins/Non-IM Contact/src/commonheaders.h
+++ b/plugins/Non-IM Contact/src/commonheaders.h
@@ -110,7 +110,6 @@ void replaceAllStrings(MCONTACT hContact);
void WriteSetting(MCONTACT hContact, char* module1, char* setting1 , char* module12, char* setting2);
//timer.c
-extern UINT_PTR timerId;
void CALLBACK timerProc();
int startTimer(int interval);
int killTimer();
@@ -122,7 +121,7 @@ extern char *szInfo;
extern char *szData;
extern HANDLE hNetlibUser;
-int db_get_static(MCONTACT hContact, const char *moduleName, const char *fn, char *buf);
+int db_get_static(MCONTACT hContact, const char *moduleName, const char *fn, char *buf, size_t cbSize);
#endif
diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp
index 9bc7750229..4e16404b4b 100644
--- a/plugins/Non-IM Contact/src/contactinfo.cpp
+++ b/plugins/Non-IM Contact/src/contactinfo.cpp
@@ -2,17 +2,17 @@
INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwnd);
{
MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam;
char name[2048];
- TranslateDialogDefault(hwnd);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact);
- if (!db_get_static(hContact, MODNAME, "Name", name)) break;
+ if (!db_get_static(hContact, MODNAME, "Name", name, SIZEOF(name))) break;
SetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, name);
- if (!db_get_static(hContact, MODNAME, "ToolTip", name)) break;
+ if (!db_get_static(hContact, MODNAME, "ToolTip", name, SIZEOF(name))) break;
SetDlgItemTextA(hwnd, IDC_TOOLTIP, name);
}
return TRUE;
@@ -22,14 +22,14 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
return TRUE;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_DISPLAY_NAME))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_DISPLAY_NAME))) {
char text[512];
- GetDlgItemTextA(hwnd,IDC_DISPLAY_NAME,text,SIZEOF(text));
+ GetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, text, SIZEOF(text));
db_set_s(hContact, MODNAME, "Name", text);
WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick");
}
@@ -38,9 +38,9 @@ INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
db_unset(hContact, MODNAME, "Nick");
}
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_TOOLTIP))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TOOLTIP))) {
char text[2048];
- GetDlgItemTextA(hwnd,IDC_TOOLTIP,text,SIZEOF(text));
+ GetDlgItemTextA(hwnd, IDC_TOOLTIP, text, SIZEOF(text));
db_set_s(hContact, MODNAME, "ToolTip", text);
WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes");
}
@@ -78,14 +78,14 @@ LRESULT CALLBACK ButtWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
return res;
}
-int BrowseForFolder(HWND hwnd,char *szPath)
+int BrowseForFolder(HWND hwnd, char *szPath)
{
- int result=0;
+ int result = 0;
LPMALLOC pMalloc;
- if (SUCCEEDED(CoGetMalloc(1,&pMalloc))) {
- ptrT tszPath( mir_a2t(szPath));
- BROWSEINFO bi={0};
+ if (SUCCEEDED(CoGetMalloc(1, &pMalloc))) {
+ ptrT tszPath(mir_a2t(szPath));
+ BROWSEINFO bi = { 0 };
bi.hwndOwner = hwnd;
bi.pszDisplayName = tszPath;
bi.lpszTitle = TranslateT("Select Folder");
@@ -95,7 +95,7 @@ int BrowseForFolder(HWND hwnd,char *szPath)
ITEMIDLIST *pidlResult = SHBrowseForFolder(&bi);
if (pidlResult) {
SHGetPathFromIDListA(pidlResult, szPath);
- mir_strcat(szPath,"\\");
+ mir_strcat(szPath, "\\");
result = 1;
}
pMalloc->Free(pidlResult);
@@ -107,36 +107,33 @@ int BrowseForFolder(HWND hwnd,char *szPath)
INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
+ TranslateDialogDefault(hwnd);
{
MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam;
- TranslateDialogDefault(hwnd);
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact);
if (!hContact)
break;
/* link*/
DBVARIANT dbv;
- if (!db_get_ts(hContact, MODNAME, "ProgramString", &dbv))
- {
+ if (!db_get_ts(hContact, MODNAME, "ProgramString", &dbv)) {
SetDlgItemText(hwnd, IDC_LINK, dbv.ptszVal);
db_free(&dbv);
}
- if (!db_get_ts(hContact, MODNAME, "ProgramParamsString", &dbv))
- {
+ if (!db_get_ts(hContact, MODNAME, "ProgramParamsString", &dbv)) {
SetDlgItemText(hwnd, IDC_PARAMS, dbv.ptszVal);
db_free(&dbv);
}
/* group*/
TCHAR *szGroup;
- for (int i=1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
- SendDlgItemMessage(hwnd, IDC_GROUP, CB_INSERTSTRING,0, LPARAM(szGroup));
+ for (int i = 1; (szGroup = pcli->pfnGetGroupName(i, NULL)) != NULL; i++)
+ SendDlgItemMessage(hwnd, IDC_GROUP, CB_INSERTSTRING, 0, LPARAM(szGroup));
- if (!db_get_ts(hContact, "CList", "Group", &dbv))
- {
+ if (!db_get_ts(hContact, "CList", "Group", &dbv)) {
SetDlgItemText(hwnd, IDC_GROUP, dbv.ptszVal);
db_free(&dbv);
}
@@ -151,38 +148,38 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
db_free(&dbv);
/* timer */
- CheckDlgButton(hwnd, CHK_USE_TIMER, db_get_b(hContact, MODNAME ,"UseTimer", 0) ? BST_CHECKED : BST_UNCHECKED);
- if (db_get_w(hContact, MODNAME ,"Timer", 15)) {
+ CheckDlgButton(hwnd, CHK_USE_TIMER, db_get_b(hContact, MODNAME, "UseTimer", 0) ? BST_CHECKED : BST_UNCHECKED);
+ if (db_get_w(hContact, MODNAME, "Timer", 15)) {
CheckDlgButton(hwnd, CHK_USE_TIMER, BST_CHECKED);
EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1);
TCHAR string[512];
- SetDlgItemText(hwnd, IDC_TIMER, _itot(db_get_w(hContact, MODNAME ,"Timer", 15), string, 10));
- if (!db_get_w(NULL, MODNAME ,"Timer", 1))
- SetDlgItemText(hwnd,IDC_TIMER_INTERVAL_MSG, TranslateT("Non-IM Contact protocol timer is Disabled"));
+ SetDlgItemText(hwnd, IDC_TIMER, _itot(db_get_w(hContact, MODNAME, "Timer", 15), string, 10));
+ if (!db_get_w(NULL, MODNAME, "Timer", 1))
+ SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, TranslateT("Non-IM Contact protocol timer is Disabled"));
else {
- mir_sntprintf(string, SIZEOF(string), TranslateT("Timer intervals... Non-IM Contact Protocol timer is %d seconds"),db_get_w(NULL, MODNAME ,"Timer", 1));
- SetDlgItemText(hwnd,IDC_TIMER_INTERVAL_MSG, string);
+ mir_sntprintf(string, SIZEOF(string), TranslateT("Timer intervals... Non-IM Contact Protocol timer is %d seconds"), db_get_w(NULL, MODNAME, "Timer", 1));
+ SetDlgItemText(hwnd, IDC_TIMER_INTERVAL_MSG, string);
}
}
/* always visible */
- if (db_get_b(hContact, MODNAME ,"AlwaysVisible", 0)) {
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible", 0)) {
CheckDlgButton(hwnd, IDC_ALWAYS_VISIBLE, BST_CHECKED);
- EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),1);
- CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME ,"VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1);
+ CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED);
}
}
return TRUE;
case WM_COMMAND:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_ALWAYS_VISIBLE:
if (IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)) {
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),1);
- CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME ,"VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 1);
+ CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME, "VisibleUnlessOffline", 1) ? BST_CHECKED : BST_UNCHECKED);
}
- else EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),0);
+ else EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE), 0);
break;
case CHK_USE_TIMER:
@@ -190,56 +187,51 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
char string[4];
EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1);
- SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME ,"Timer", 15), string, 10));
+ SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME, "Timer", 15), string, 10));
}
else EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 0);
break;
case IDC_OPEN_FILE:
- {
- char szFileName[512];
- if ( Openfile(szFileName,1))
- SetDlgItemTextA(hwnd, IDC_LINK, szFileName);
- }
+ char szFileName[512];
+ if (Openfile(szFileName, 1))
+ SetDlgItemTextA(hwnd, IDC_LINK, szFileName);
break;
case IDC_OPEN_FOLDER:
- {
- char szFileName[512];
- if (BrowseForFolder(hwnd, szFileName)) {
- mir_snprintf(szFileName, SIZEOF(szFileName), "%s ,/e", szFileName);
- SetDlgItemTextA(hwnd, IDC_LINK, "explorer.exe");
- SetDlgItemTextA(hwnd, IDC_PARAMS, szFileName);
- }
+ if (BrowseForFolder(hwnd, szFileName)) {
+ mir_snprintf(szFileName, SIZEOF(szFileName), "%s ,/e", szFileName);
+ SetDlgItemTextA(hwnd, IDC_LINK, "explorer.exe");
+ SetDlgItemTextA(hwnd, IDC_PARAMS, szFileName);
}
}
break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- int status = GetLCStatus(0,0);
+ int status = GetLCStatus(0, 0);
MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_LINK))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_LINK))) {
char text[512];
- GetDlgItemTextA(hwnd,IDC_LINK,text,SIZEOF(text));
+ GetDlgItemTextA(hwnd, IDC_LINK, text, SIZEOF(text));
db_set_s(hContact, MODNAME, "ProgramString", text);
WriteSetting(hContact, MODNAME, "ProgramString", MODNAME, "Program");
}
else db_unset(hContact, MODNAME, "ProgramString");
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_PARAMS))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_PARAMS))) {
char text[512];
- GetDlgItemTextA(hwnd,IDC_PARAMS,text,SIZEOF(text));
+ GetDlgItemTextA(hwnd, IDC_PARAMS, text, SIZEOF(text));
db_set_s(hContact, MODNAME, "ProgramParamsString", text);
WriteSetting(hContact, MODNAME, "ProgramParamsString", MODNAME, "ProgramParams");
}
else db_unset(hContact, MODNAME, "ProgramParamsString");
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_GROUP))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_GROUP))) {
TCHAR text[512];
GetDlgItemText(hwnd, IDC_GROUP, text, SIZEOF(text));
Clist_CreateGroup(NULL, text);
@@ -247,7 +239,7 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
else db_unset(hContact, "CList", "Group");
- for (int i = ID_STATUS_ONLINE; i<=ID_STATUS_OUTTOLUNCH; i++)
+ for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_OUTTOLUNCH; i++)
if (IsDlgButtonChecked(hwnd, i))
db_set_w(hContact, MODNAME, "Icon", (WORD)i);
@@ -258,9 +250,9 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE);
if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) {
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_TIMER))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER))) {
TCHAR text[512];
- GetDlgItemText(hwnd,IDC_TIMER,text,SIZEOF(text));
+ GetDlgItemText(hwnd, IDC_TIMER, text, SIZEOF(text));
db_set_w(hContact, MODNAME, "Timer", (WORD)_ttoi(text));
}
else db_set_w(hContact, MODNAME, "Timer", 15);
@@ -280,15 +272,15 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
char* copyReplaceString(char* oldStr, char* newStr, char* findStr, char* replaceWithStr)
{
- int i=0;
+ int i = 0;
while (oldStr[i] != '\0') {
// msg(&oldStr[i],"");
- if (!strncmp(&oldStr[i],findStr, strlen(findStr))) {
- strcat(newStr,replaceWithStr);
+ if (!strncmp(&oldStr[i], findStr, strlen(findStr))) {
+ strcat(newStr, replaceWithStr);
i += (int)strlen(findStr);
}
else {
- strncat(newStr,&oldStr[i],1);
+ strncat(newStr, &oldStr[i], 1);
i++;
}
}
@@ -299,18 +291,15 @@ char* copyReplaceString(char* oldStr, char* newStr, char* findStr, char* replace
INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
- {
- MCONTACT hContact = (MCONTACT)((PROPSHEETPAGE*)lParam)->lParam;
- TranslateDialogDefault(hwnd);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)hContact);
- }
+ TranslateDialogDefault(hwnd);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, ((PROPSHEETPAGE*)lParam)->lParam);
return TRUE;
case WM_COMMAND:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_EXPORT:
ExportContact((MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA));
break;
@@ -319,24 +308,24 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE))) {
char newString[MAX_REPLACES][512], oldString[MAX_REPLACES][512];
char dbVar1[2000], dbVar2[2000];
- int i=0,j=0, k=0;
+ int i = 0, j = 0, k = 0;
char *string = oldString[k];
MCONTACT hContact1 = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA), hContact2;
- if (db_get_static(hContact1, MODNAME, "Name", dbVar1)) {
- char *replace = (char*)malloc(GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) +1);
- GetDlgItemTextA(hwnd, IDC_STRING_REPLACE, replace, GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) +1);
+ if (db_get_static(hContact1, MODNAME, "Name", dbVar1, SIZEOF(dbVar1))) {
+ char *replace = (char*)malloc(GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) + 1);
+ GetDlgItemTextA(hwnd, IDC_STRING_REPLACE, replace, GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) + 1);
// get the list of replace strings
while (replace[i] != '\0') {
if (replace[i] == ',') {
string = newString[k];
- j=0;
+ j = 0;
}
- else if (!strncmp(replace + i, "\r\n",2)) {
+ else if (!strncmp(replace + i, "\r\n", 2)) {
if (string == newString[k])
k--;
if (k == MAX_REPLACES) break;
string = oldString[++k];
- i+=2;
+ i += 2;
continue;
}
else {
@@ -346,46 +335,46 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
i++;
}
free(replace);
- hContact2 =(MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact2,(LPARAM)MODNAME);
+ hContact2 = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact2, (LPARAM)MODNAME);
CallService(MS_IGNORE_IGNORE, (WPARAM)hContact2, IGNOREEVENT_USERONLINE);
db_set_s(hContact2, MODNAME, "Nick", Translate("New Non-IM Contact"));
// blank dbVar2 so the replaceing doesnt crash..
strcpy(dbVar2, "");
// copy the name (dbVar1 is the name)
- for (i=0;i<=k;i++)
- copyReplaceString(dbVar1, dbVar2, oldString[i],newString[i] );
+ for (i = 0; i <= k; i++)
+ copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]);
db_set_s(hContact2, MODNAME, "Name", dbVar2);
// copy the ProgramString
- if (db_get_static(hContact1, MODNAME, "ProgramString",dbVar1)) {
+ if (db_get_static(hContact1, MODNAME, "ProgramString", dbVar1, SIZEOF(dbVar1))) {
strcpy(dbVar2, "");
- for (i=0;i<=k;i++)
- copyReplaceString(dbVar1, dbVar2, oldString[i],newString[i] );
+ for (i = 0; i <= k; i++)
+ copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]);
db_set_s(hContact2, MODNAME, "ProgramString", dbVar2);
}
// copy the ProgramParamString
- if (db_get_static(hContact1, MODNAME, "ProgramParamString",dbVar1)) {
+ if (db_get_static(hContact1, MODNAME, "ProgramParamString", dbVar1, SIZEOF(dbVar1))) {
strcpy(dbVar2, "");
- for (i=0;i<=k;i++)
- copyReplaceString(dbVar1, dbVar2, oldString[i],newString[i] );
+ for (i = 0; i <= k; i++)
+ copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]);
db_set_s(hContact2, MODNAME, "ProgramParamString", dbVar2);
}
// copy the group
- if (db_get_static(hContact1, "CList", "Group",dbVar1)) {
+ if (db_get_static(hContact1, "CList", "Group", dbVar1, SIZEOF(dbVar1))) {
strcpy(dbVar2, "");
- for (i=0;i<=k;i++)
- copyReplaceString(dbVar1, dbVar2, oldString[i],newString[i] );
+ for (i = 0; i <= k; i++)
+ copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]);
db_set_s(hContact2, "CList", "Group", dbVar2);
}
// copy the ToolTip
- if (db_get_static(hContact1, MODNAME, "ToolTip",dbVar1)) {
+ if (db_get_static(hContact1, MODNAME, "ToolTip", dbVar1, SIZEOF(dbVar1))) {
strcpy(dbVar2, "");
- for (i=0;i<=k;i++)
- copyReplaceString(dbVar1, dbVar2, oldString[i],newString[i] );
+ for (i = 0; i <= k; i++)
+ copyReplaceString(dbVar1, dbVar2, oldString[i], newString[i]);
db_set_s(hContact2, MODNAME, "ToolTip", dbVar2);
}
@@ -396,34 +385,34 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
//icon
db_set_w(hContact2, MODNAME, "Icon", (WORD)db_get_w(hContact1, MODNAME, "Icon", 40072));
replaceAllStrings(hContact2);
- }
+ }
}
else {
char dbVar1[2000];
MCONTACT hContact1 = (MCONTACT)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (db_get_static(hContact1, MODNAME, "Name", dbVar1)) {
- MCONTACT hContact2 = (MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ if (db_get_static(hContact1, MODNAME, "Name", dbVar1, SIZEOF(dbVar1))) {
+ MCONTACT hContact2 = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
if (!hContact2) {
- msg("contact did not get created","");
+ msg("contact did not get created", "");
return 0;
}
- CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact2,(LPARAM)MODNAME);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact2, (LPARAM)MODNAME);
CallService(MS_IGNORE_IGNORE, (WPARAM)hContact2, IGNOREEVENT_USERONLINE);
db_set_s(hContact2, MODNAME, "Nick", Translate("New Non-IM Contact"));
db_set_s(hContact2, MODNAME, "Name", dbVar1);
- if (db_get_static(hContact1, MODNAME, "ProgramString",dbVar1))
+ if (db_get_static(hContact1, MODNAME, "ProgramString", dbVar1, SIZEOF(dbVar1)))
db_set_s(hContact2, MODNAME, "ProgramString", dbVar1);
// copy the ProgramParamString
- if (db_get_static(hContact1, MODNAME, "ProgramParamString",dbVar1))
+ if (db_get_static(hContact1, MODNAME, "ProgramParamString", dbVar1, SIZEOF(dbVar1)))
db_set_s(hContact2, MODNAME, "ProgramParamString", dbVar1);
// copy the group
- if (db_get_static(hContact1, "CList", "Group",dbVar1))
+ if (db_get_static(hContact1, "CList", "Group", dbVar1, SIZEOF(dbVar1)))
db_set_s(hContact2, "CList", "Group", dbVar1);
// copy the ToolTip
- if (db_get_static(hContact1, MODNAME, "ToolTip",dbVar1))
+ if (db_get_static(hContact1, MODNAME, "ToolTip", dbVar1, SIZEOF(dbVar1)))
db_set_s(hContact2, MODNAME, "ToolTip", dbVar1);
// timer
@@ -440,7 +429,7 @@ INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
@@ -458,24 +447,21 @@ void ExportContact(MCONTACT hContact)
char DBVar[1024];
int tmp;
- if (Openfile(szFileName, 0))
- {
+ if (Openfile(szFileName, 0)) {
// if (tmp = MessageBox(0, "Do you want to overwrite the contents of the file?\r\n\r\nPressing No will append this contact to the end of the file.",modFullname, MB_YESNO) == IDYES)
// file = fopen(szFileName, "w");
// else
FILE *file = fopen(szFileName, "a");
- if (file)
- {
- if (db_get_static(hContact, MODNAME, "Name", DBVar))
- {
+ if (file) {
+ if (db_get_static(hContact, MODNAME, "Name", DBVar, SIZEOF(DBVar))) {
fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ProgramString", DBVar))
+ if (db_get_static(hContact, MODNAME, "ProgramString", DBVar, SIZEOF(DBVar)))
fprintf(file, "ProgramString=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar))
+ if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar, SIZEOF(DBVar)))
fprintf(file, "ProgramParamString=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ToolTip", DBVar))
+ if (db_get_static(hContact, MODNAME, "ToolTip", DBVar, SIZEOF(DBVar)))
fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
- if (db_get_static(hContact, "CList", "Group", DBVar))
+ if (db_get_static(hContact, "CList", "Group", DBVar, SIZEOF(DBVar)))
fprintf(file, "Group=%s\r\n", DBVar);
if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072))
fprintf(file, "Icon=%d\r\n", tmp);
@@ -487,7 +473,7 @@ void ExportContact(MCONTACT hContact)
fprintf(file, "Timer=%d\r\n", tmp);
fprintf(file, "[/Non-IM Contact]\r\n");
}
- else ("Contact is invalid",modFullname);
+ else ("Contact is invalid", modFullname);
fclose(file);
}
}
@@ -499,58 +485,58 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam)
char name[256] = "", program[256] = "", programparam[256] = "", group[256] = "", tooltip[3000] = "", line[2001] = "";
int icon = 40072, usetimer = 0, minutes = 1, timer = 0;
char fn[MAX_PATH];
- int i,j, contactDone = 0;
- if ( !Openfile(fn, 1))
+ int i, j, contactDone = 0;
+ if (!Openfile(fn, 1))
return 1;
FILE *file = fopen(fn, "r");
if (!file)
return 1;
- while (fgets(line,2000,file)) {
+ while (fgets(line, 2000, file)) {
if (!strcmp(line, "\r\n\0"))
continue;
- if (!strcmp(line,"[Non-IM Contact]\r\n"))
+ if (!strcmp(line, "[Non-IM Contact]\r\n"))
contactDone = 0;
- else if (!strncmp(line, "Name=" ,strlen("Name="))) {
- i = (int)strlen("Name=");j=0;
+ else if (!strncmp(line, "Name=", strlen("Name="))) {
+ i = (int)strlen("Name="); j = 0;
while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
name[j] = line[i++];
name[++j] = '\0';
}
- contactDone =1;
+ contactDone = 1;
}
- else if (!strncmp(line, "ProgramString=" ,strlen("ProgramString="))) {
- i = (int)strlen("ProgramString=");j=0;
+ else if (!strncmp(line, "ProgramString=", strlen("ProgramString="))) {
+ i = (int)strlen("ProgramString="); j = 0;
while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
program[j] = line[i++];
program[++j] = '\0';
}
}
- else if (!strncmp(line, "ProgramParamString=" ,strlen("ProgramParamString="))) {
- i = (int)strlen("ProgramParamString=");j=0;
+ else if (!strncmp(line, "ProgramParamString=", strlen("ProgramParamString="))) {
+ i = (int)strlen("ProgramParamString="); j = 0;
while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
programparam[j] = line[i++];
programparam[++j] = '\0';
}
}
- else if (!strncmp(line, "Group=" ,strlen("Group="))) {
- i = (int)strlen("Group=");j=0;
+ else if (!strncmp(line, "Group=", strlen("Group="))) {
+ i = (int)strlen("Group="); j = 0;
while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
group[j] = line[i++];
group[++j] = '\0';
}
}
- else if (!strncmp(line, "ToolTip=" ,strlen("ToolTip="))) {
+ else if (!strncmp(line, "ToolTip=", strlen("ToolTip="))) {
i = (int)strlen("ToolTip=");
strcpy(tooltip, &line[i]);
- fgets(line,2000,file);
- while (!strstr(line,"</tooltip>\r\n")) {
- strcat(tooltip,line);
- fgets(line,2000,file);
+ fgets(line, 2000, file);
+ while (!strstr(line, "</tooltip>\r\n")) {
+ strcat(tooltip, line);
+ fgets(line, 2000, file);
}
// the line that has the </tooltip>
- strncat(tooltip,line, strlen(line) - strlen("</tooltip>\r\n"));
+ strncat(tooltip, line, strlen(line) - strlen("</tooltip>\r\n"));
}
else if (!strncmp(line, "Icon=", strlen("Icon="))) {
i = (int)strlen("Icon=");
@@ -560,7 +546,7 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam)
i = (int)strlen("UseTimer=");
sscanf(&line[i], "%d", &usetimer);
}
- else if (!strncmp(line, "Timer=" ,strlen("Timer="))) {
+ else if (!strncmp(line, "Timer=", strlen("Timer="))) {
i = (int)strlen("Timer=");
sscanf(&line[i], "%d", &timer);
}
@@ -568,34 +554,34 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam)
i = (int)strlen("Minutes=");
sscanf(&line[i], "%d", &minutes);
}
- else if (contactDone && !strcmp(line,"[/Non-IM Contact]\r\n")) {
+ else if (contactDone && !strcmp(line, "[/Non-IM Contact]\r\n")) {
if (!name) continue;
size_t size = strlen(name) + strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1;
char *msg = (char*)malloc(size);
mir_snprintf(msg, size, "Do you want to import this Non-IM Contact?\r\n\r\nName: %s\r\n", name);
if (program) {
- msg = (char*)realloc(msg, strlen(msg) + strlen(program) +strlen("Program: \r\n") +1);
+ msg = (char*)realloc(msg, strlen(msg) + strlen(program) + strlen("Program: \r\n") + 1);
strcat(msg, "Program: ");
- strcat(msg,program);
- strcat(msg,"\r\n");
+ strcat(msg, program);
+ strcat(msg, "\r\n");
}
if (programparam) {
- msg = (char*)realloc(msg, strlen(msg) + strlen(programparam) +strlen("Program Parameters: \r\n") +1);
+ msg = (char*)realloc(msg, strlen(msg) + strlen(programparam) + strlen("Program Parameters: \r\n") + 1);
strcat(msg, "Program Parameters: ");
- strcat(msg,programparam);
- strcat(msg,"\r\n");
+ strcat(msg, programparam);
+ strcat(msg, "\r\n");
}
if (tooltip) {
- msg = (char*)realloc(msg, strlen(msg) + strlen(tooltip) +strlen("ToolTip: \r\n") +1);
+ msg = (char*)realloc(msg, strlen(msg) + strlen(tooltip) + strlen("ToolTip: \r\n") + 1);
strcat(msg, "ToolTip: ");
- strcat(msg,tooltip);
- strcat(msg,"\r\n");
+ strcat(msg, tooltip);
+ strcat(msg, "\r\n");
}
if (group) {
- msg = (char*)realloc(msg, strlen(msg) + strlen(group) +strlen("Group: \r\n") +1);
+ msg = (char*)realloc(msg, strlen(msg) + strlen(group) + strlen("Group: \r\n") + 1);
strcat(msg, "Group: ");
- strcat(msg,group);
- strcat(msg,"\r\n");
+ strcat(msg, group);
+ strcat(msg, "\r\n");
}
if (icon) {
char tmp[64];
@@ -621,31 +607,31 @@ INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam)
free(msg);
continue;
}
- char *msgtemp = (char*)realloc(msg, strlen(msg) + strlen(tmp) +1);
+ char *msgtemp = (char*)realloc(msg, strlen(msg) + strlen(tmp) + 1);
if (msgtemp) {
msg = msgtemp;
- strcat(msg,tmp);
+ strcat(msg, tmp);
}
}
if (usetimer && timer) {
- char tmp[64],tmp2[8];
+ char tmp[64], tmp2[8];
if (minutes)
- strcpy(tmp2,"Minutes");
- else strcpy(tmp2,"Seconds");
- mir_snprintf(tmp, SIZEOF(tmp), "UseTimer: Yes\r\nTimer: %d %s",timer, tmp2);
- char *msgtemp = (char*)realloc(msg, strlen(msg) + strlen(tmp) +1);
+ strcpy(tmp2, "Minutes");
+ else strcpy(tmp2, "Seconds");
+ mir_snprintf(tmp, SIZEOF(tmp), "UseTimer: Yes\r\nTimer: %d %s", timer, tmp2);
+ char *msgtemp = (char*)realloc(msg, strlen(msg) + strlen(tmp) + 1);
if (msgtemp) {
msg = msgtemp;
- strcat(msg,tmp);
+ strcat(msg, tmp);
}
}
- if (MessageBoxA(0,msg,modFullname,MB_YESNO) == IDYES) {
+ if (MessageBoxA(0, msg, modFullname, MB_YESNO) == IDYES) {
if (!(hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0))) {
- msg("contact did get created","");
+ msg("contact did get created", "");
continue;
}
- CallService(MS_PROTO_ADDTOCONTACT,hContact,(LPARAM)MODNAME);
+ CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
db_set_s(hContact, MODNAME, "Name", name);
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp
index d48e53a45b..0702d63a6c 100644
--- a/plugins/Non-IM Contact/src/dialog.cpp
+++ b/plugins/Non-IM Contact/src/dialog.cpp
@@ -17,51 +17,44 @@ filename(0) <- will display the filename of the 0th file\r\nfile(0)wholeline(
INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TCHAR tmp[5];
- TranslateDialogDefault(hwnd);
- CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(NULL, MODNAME, "AwayAsStatus", 0) ? BST_CHECKED : BST_UNCHECKED);
- if (db_get_w(NULL, MODNAME, "Timer", 1))
- {
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_INT),1);
- SetDlgItemText(hwnd, IDC_TIMER_INT, _itot(db_get_w(NULL, MODNAME, "Timer", 1),tmp,10));
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_TEXT),1);
- }
- else
- {
- CheckDlgButton(hwnd, IDC_DISABLETIMER, BST_CHECKED);
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_INT),0);
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_TEXT),0);
- }
-
+ TCHAR tmp[5];
+ TranslateDialogDefault(hwnd);
+ CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(NULL, MODNAME, "AwayAsStatus", 0) ? BST_CHECKED : BST_UNCHECKED);
+ if (db_get_w(NULL, MODNAME, "Timer", 1)) {
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_INT), 1);
+ SetDlgItemText(hwnd, IDC_TIMER_INT, _itot(db_get_w(NULL, MODNAME, "Timer", 1), tmp, 10));
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_TEXT), 1);
+ }
+ else {
+ CheckDlgButton(hwnd, IDC_DISABLETIMER, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_INT), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_TEXT), 0);
}
return TRUE;
+
case WM_COMMAND:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_DISABLETIMER:
- if (IsDlgButtonChecked(hwnd, IDC_DISABLETIMER))
- {
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_INT),0);
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_TEXT),0);
+ if (IsDlgButtonChecked(hwnd, IDC_DISABLETIMER)) {
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_INT), 0);
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_TEXT), 0);
}
- else
- {
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_TEXT),1);
- EnableWindow(GetDlgItem(hwnd,IDC_TIMER_INT),1);
+ else {
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_TEXT), 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER_INT), 1);
if (!GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT)))
- SetDlgItemText(hwnd, IDC_TIMER_INT,_T("1"));
+ SetDlgItemText(hwnd, IDC_TIMER_INT, _T("1"));
}
break;
-
-
return TRUE;
}
break;
+
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
@@ -69,9 +62,9 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
db_set_b(NULL, MODNAME, "AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE));
if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_DISABLETIMER) && GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT))) {
GetDlgItemText(hwnd, IDC_TIMER_INT, tmp, SIZEOF(tmp));
- db_set_w(NULL, MODNAME, "Timer",(WORD)_ttoi(tmp));
+ db_set_w(NULL, MODNAME, "Timer", (WORD)_ttoi(tmp));
}
- else db_set_w(NULL, MODNAME, "Timer",0);
+ else db_set_w(NULL, MODNAME, "Timer", 0);
return TRUE;
}
}
@@ -80,37 +73,38 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
return FALSE;
}
-
// string replace test window thingamijig....
// struct to keep track of ()'s in the test sring window
#define MAX_BRACES 32
#define VARS 7
-struct braces {
+struct braces
+{
char var[64];
int idCtrl;
-} braceList[VARS] =
+}
+braceList[VARS] =
{
- {"file(", IDC_FILE},
- {"start(", IDC_START},
- {"end(", IDC_END},
- {"csv(", IDC_CSV},
- {"wholeline(", IDC_WHOLELINE},
- {"filename(", IDC_FILENAME},
- {"line(", IDC_LINE}
+ { "file(", IDC_FILE },
+ { "start(", IDC_START },
+ { "end(", IDC_END },
+ { "csv(", IDC_CSV },
+ { "wholeline(", IDC_WHOLELINE },
+ { "filename(", IDC_FILENAME },
+ { "line(", IDC_LINE }
};
-int braceOrder[MAX_BRACES] = {0};
+int braceOrder[MAX_BRACES] = { 0 };
INT_PTR CALLBACK HelpWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
SetDlgItemText(hwnd, IDC_HELPTEXT, NIM_HELP_TEXT);
TranslateDialogDefault(hwnd);
return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDOK:
DestroyWindow(hwnd);
break;
@@ -122,15 +116,15 @@ INT_PTR CALLBACK HelpWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
return TRUE;
case WM_COMMAND:
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_HELPMSG:
- CreateDialog(hInst,MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
+ CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
break;
case IDCANCEL:
@@ -140,18 +134,18 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
case IDC_STRING:
if (HIWORD(wParam) == EN_CHANGE) {
char tmp[MAX_STRING_LENGTH];
- int i=0,j;
+ int i = 0, j;
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING))) {
GetDlgItemTextA(hwnd, IDC_STRING, tmp, SIZEOF(tmp));
- if (tmp[strlen(tmp)-1] == '(') {
- for (i=0; i<VARS; i++) {
- if (!strcmp(braceList[i].var,&tmp[strlen(tmp)-strlen(braceList[i].var)])) {
- for (j=0;j<MAX_BRACES;j++) {
+ if (tmp[strlen(tmp) - 1] == '(') {
+ for (i = 0; i < VARS; i++) {
+ if (!strcmp(braceList[i].var, &tmp[strlen(tmp) - strlen(braceList[i].var)])) {
+ for (j = 0; j < MAX_BRACES; j++) {
if (!braceOrder[j]) {
- braceOrder[j]=i;
- EnableWindow(GetDlgItem(hwnd, braceList[i].idCtrl),1);
+ braceOrder[j] = i;
+ EnableWindow(GetDlgItem(hwnd, braceList[i].idCtrl), 1);
if (j)
- EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j-1]].idCtrl),0);
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j - 1]].idCtrl), 0);
break;
}
}
@@ -159,22 +153,22 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
}
}
}
- else if (tmp[strlen(tmp)-1] == ')') {
- for (j=0; j<MAX_BRACES; j++) {
+ else if (tmp[strlen(tmp) - 1] == ')') {
+ for (j = 0; j < MAX_BRACES; j++) {
if (!braceOrder[j]) {
- EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j-1]].idCtrl),0);
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j - 1]].idCtrl), 0);
if (j > 1)
- EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j-2]].idCtrl),1);
- braceOrder[j-1] = 0;
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j - 2]].idCtrl), 1);
+ braceOrder[j - 1] = 0;
break;
}
}
}
}
else {
- for (j=0; j<MAX_BRACES; j++) {
+ for (j = 0; j < MAX_BRACES; j++) {
if (!braceOrder[j]) break;
- EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j]].idCtrl),0);
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j]].idCtrl), 0);
}
}
}
@@ -187,7 +181,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
GetDlgItemTextA(hwnd, IDC_STRING, str2replace, SIZEOF(str2replace));
switch (stringReplacer(str2replace, replacedString, NULL)) {
case ERROR_NO_LINE_AFTER_VAR_F:
- mir_snprintf(replacedString, SIZEOF(replacedString), "ERROR: no %s","%line or %wholeline or %lastline after %fn");
+ mir_snprintf(replacedString, SIZEOF(replacedString), "ERROR: no %s", "%line or %wholeline or %lastline after %fn");
error = 1;
break;
case ERROR_LINE_NOT_READ:
@@ -204,7 +198,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
SetDlgItemTextA(hwnd, IDC_ANSWER, replacedString);
}
}
- break;
+ break;
}
return FALSE;
}
@@ -217,7 +211,7 @@ INT_PTR testStringReplacer(WPARAM, LPARAM)
INT_PTR LoadFilesDlg(WPARAM, LPARAM)
{
- CreateDialog(hInst,MAKEINTRESOURCE(IDD_ADD_FILE),0,DlgProcFiles);
+ CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADD_FILE), 0, DlgProcFiles);
return 0;
}
@@ -230,7 +224,7 @@ static int CALLBACK PropSheetProc(HWND hwnd, UINT uMsg, LPARAM lParam)
// dialog box template
if (((DLGTEMPLATEEX*)lParam)->signature == 0xFFFF)
((DLGTEMPLATEEX*)lParam)->style &= ~DS_CONTEXTHELP;
- else
+ else
((LPDLGTEMPLATE)lParam)->style &= ~DS_CONTEXTHELP;
return TRUE;
@@ -249,7 +243,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
psp[0].hInstance = hInst;
psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
- psp[0].pszIcon = NULL;
+ psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = DlgProcContactInfo;
psp[0].pszTitle = Translate("Contacts Display Info");
psp[0].lParam = hContact;
@@ -260,7 +254,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
psp[1].hInstance = hInst;
psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
- psp[1].pszIcon = NULL;
+ psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = DlgProcOtherStuff;
psp[1].pszTitle = Translate("Link and Contact list Settings");
psp[1].lParam = hContact;
@@ -271,7 +265,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
psp[2].hInstance = hInst;
psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
- psp[2].pszIcon = NULL;
+ psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = DlgProcCopy;
psp[2].pszTitle = Translate("Copy Contact");
psp[2].lParam = hContact;
@@ -282,7 +276,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
psp[3].hInstance = hInst;
psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
- psp[3].pszIcon = NULL;
+ psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = DlgProcFiles;
psp[3].pszTitle = Translate("Files");
psp[3].lParam = 0;
@@ -293,7 +287,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
psh.hInstance = hInst;
psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
- db_get_static(hContact, MODNAME, "Nick", nick);
+ db_get_static(hContact, MODNAME, "Nick", nick, SIZEOF(nick));
mir_snprintf(title, SIZEOF(title), Translate("Edit Non-IM Contact \"%s\""), nick);
psh.pszCaption = title;
psh.nPages = SIZEOF(psp);
@@ -304,33 +298,33 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
PropertySheetA(&psh);
}
-INT_PTR addContact(WPARAM wParam,LPARAM lParam)
+INT_PTR addContact(WPARAM wParam, LPARAM lParam)
{
char tmp[256];
- MCONTACT hContact = (MCONTACT) CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT,hContact,(LPARAM)MODNAME);
+ MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_ts(hContact, MODNAME, "Nick", TranslateT("New Non-IM Contact"));
DoPropertySheet(hContact, hInst);
- if (!db_get_static(hContact, MODNAME, "Name", tmp))
- CallService(MS_DB_CONTACT_DELETE,hContact,0);
+ if (!db_get_static(hContact, MODNAME, "Name", tmp, SIZEOF(tmp)))
+ CallService(MS_DB_CONTACT_DELETE, hContact, 0);
replaceAllStrings(hContact);
return 0;
}
-INT_PTR editContact(WPARAM wParam,LPARAM lParam)
+INT_PTR editContact(WPARAM wParam, LPARAM lParam)
{
MCONTACT hContact = wParam;
char tmp[256];
if (!hContact) {
hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT,hContact,(LPARAM)MODNAME);
+ CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
}
DoPropertySheet(hContact, hInst);
- if (!db_get_static(hContact, MODNAME, "Name", tmp))
- CallService(MS_DB_CONTACT_DELETE,hContact,0);
+ if (!db_get_static(hContact, MODNAME, "Name", tmp, SIZEOF(tmp)))
+ CallService(MS_DB_CONTACT_DELETE, hContact, 0);
replaceAllStrings(hContact);
return 0;
}
diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp
index 704a7533f3..1c183c482d 100644
--- a/plugins/Non-IM Contact/src/files.cpp
+++ b/plugins/Non-IM Contact/src/files.cpp
@@ -1,13 +1,13 @@
#include "commonheaders.h"
-INT_PTR exportContacts(WPARAM wParam,LPARAM lParam)
+INT_PTR exportContacts(WPARAM wParam, LPARAM lParam)
{
char fn[MAX_PATH];
if (!Openfile(fn, 0))
return 0;
FILE* file;
- if (MessageBox(0, TranslateT("Do you want to overwrite the contents of the file?\r\n\r\nPressing No will append these contacts to the end of the file."),_T(modFullname), MB_YESNO) == IDYES)
+ if (MessageBox(0, TranslateT("Do you want to overwrite the contents of the file?\r\n\r\nPressing No will append these contacts to the end of the file."), _T(modFullname), MB_YESNO) == IDYES)
file = fopen(fn, "w");
else
file = fopen(fn, "a");
@@ -17,15 +17,15 @@ INT_PTR exportContacts(WPARAM wParam,LPARAM lParam)
for (MCONTACT hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) {
int tmp;
char DBVar[1024];
- if (db_get_static(hContact, MODNAME, "Name", DBVar)) {
+ if (db_get_static(hContact, MODNAME, "Name", DBVar, SIZEOF(DBVar))) {
fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ProgramString", DBVar))
+ if (db_get_static(hContact, MODNAME, "ProgramString", DBVar, SIZEOF(DBVar)))
fprintf(file, "ProgramString=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar))
+ if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar, SIZEOF(DBVar)))
fprintf(file, "ProgramParamString=%s\r\n", DBVar);
- if (db_get_static(hContact, MODNAME, "ToolTip", DBVar))
+ if (db_get_static(hContact, MODNAME, "ToolTip", DBVar, SIZEOF(DBVar)))
fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
- if (db_get_static(hContact, "CList", "Group", DBVar))
+ if (db_get_static(hContact, "CList", "Group", DBVar, SIZEOF(DBVar)))
fprintf(file, "Group=%s\r\n", DBVar);
if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072))
fprintf(file, "Icon=%d\r\n", tmp);
@@ -55,7 +55,7 @@ int Openfile(char *outputFile, int saveOpen) //0=save, 1=open
OPENFILENAMEA ofn = { sizeof(ofn) };
ofn.lpstrFile = filename;
ofn.lpstrFilter = filter;
- ofn.Flags = saveOpen? OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_SHAREAWARE | OFN_PATHMUSTEXIST: OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST;
+ ofn.Flags = saveOpen ? OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_SHAREAWARE | OFN_PATHMUSTEXIST : OFN_HIDEREADONLY | OFN_SHAREAWARE | OFN_PATHMUSTEXIST;
ofn.lpstrTitle = title;
ofn.nMaxFile = MAX_PATH;
@@ -65,23 +65,21 @@ int Openfile(char *outputFile, int saveOpen) //0=save, 1=open
r = GetSaveFileNameA(&ofn);
if (!r)
return 0;
- mir_strcpy(outputFile,filename);
+ mir_strcpy(outputFile, filename);
return 1;
}
-
void reloadFiles(HWND fileList)
{
int i, index;
char file[MAX_PATH], fn[6];
- SendMessage(fileList,CB_RESETCONTENT, 0,0);
- for (i=0; ;i++)
- {
+ SendMessage(fileList, CB_RESETCONTENT, 0, 0);
+ for (i = 0;; i++) {
mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- if (db_get_static(NULL, MODNAME, fn, file)) {
- index = SendMessageA(fileList, CB_ADDSTRING,0, (LPARAM)file);
- SendMessage(fileList, CB_SETITEMDATA, index, (LPARAM)i);
- SendMessage(fileList, CB_SETCURSEL, index,0);
+ if (db_get_static(NULL, MODNAME, fn, file, SIZEOF(file))) {
+ index = SendMessageA(fileList, CB_ADDSTRING, 0, (LPARAM)file);
+ SendMessage(fileList, CB_SETITEMDATA, index, (LPARAM)i);
+ SendMessage(fileList, CB_SETCURSEL, index, 0);
SetDlgItemTextA(GetParent(fileList), IDC_FN, _itoa(i, fn, 10));
/* add the file contents to the edit box */
}
@@ -92,9 +90,8 @@ void reloadFiles(HWND fileList)
int savehtml(char* outFile)
{
FILE* file = fopen(outFile, "w");
- if (!file)
- {
- fclose(file);
+ if (!file) {
+ fclose(file);
return 0;
}
fprintf(file, "%s", szInfo);
@@ -104,39 +101,38 @@ int savehtml(char* outFile)
void readFile(HWND hwnd)
{
- int lineNumber, fileLength=0, width=0;
+ int lineNumber, fileLength = 0, width = 0;
char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH], fn[8];
- int fileNumber = SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETCURSEL, 0,0);
+ int fileNumber = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
mir_snprintf(fn, SIZEOF(fn), "fn%d", fileNumber);
- if (!db_get_static(NULL, MODNAME, fn, szFileName)) {
- msg(Translate("File couldn't be opened"),fn);
+ if (!db_get_static(NULL, MODNAME, fn, szFileName, SIZEOF(szFileName))) {
+ msg(Translate("File couldn't be opened"), fn);
return;
}
- if ( !strncmp("http://", szFileName, strlen("http://")) || !strncmp("https://", szFileName, strlen("https://")))
+ if (!strncmp("http://", szFileName, strlen("http://")) || !strncmp("https://", szFileName, strlen("https://")))
mir_snprintf(szFileName, SIZEOF(szFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), fileNumber);
- FILE *filen = fopen(szFileName,"r");
+ FILE *filen = fopen(szFileName, "r");
if (!filen) {
- MessageBox(0, TranslateT("File couldn't be opened,2"), _T(modFullname),MB_OK);
+ MessageBox(0, TranslateT("File couldn't be opened,2"), _T(modFullname), MB_OK);
return;
}
lineNumber = 0;
- SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS,LB_RESETCONTENT, 0,0);
- while (lineNumber < (MAXLINES) && (fgets(temp, MAX_STRING_LENGTH, filen)))
- {
+ SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_RESETCONTENT, 0, 0);
+ while (lineNumber < (MAXLINES) && (fgets(temp, MAX_STRING_LENGTH, filen))) {
if (temp[0] == '\t') temp[0] = ' ';
- if (temp[strlen(temp)-1]=='\n' && temp[strlen(temp)-2]=='\r')
- temp[strlen(temp)-2]='\0';
- else if (temp[strlen(temp)-1]=='\n')
- temp[strlen(temp)-1]='\0';
- else temp[strlen(temp)]='\0';
+ if (temp[strlen(temp) - 1] == '\n' && temp[strlen(temp) - 2] == '\r')
+ temp[strlen(temp) - 2] = '\0';
+ else if (temp[strlen(temp) - 1] == '\n')
+ temp[strlen(temp) - 1] = '\0';
+ else temp[strlen(temp)] = '\0';
mir_snprintf(temp1, SIZEOF(temp1), Translate("line(%-3d) = | %s"), lineNumber, temp);
- SendDlgItemMessageA(hwnd, IDC_FILE_CONTENTS,LB_ADDSTRING,0,(LPARAM)temp1);
+ SendDlgItemMessageA(hwnd, IDC_FILE_CONTENTS, LB_ADDSTRING, 0, (LPARAM)temp1);
lineNumber++;
fileLength++;
- if ((unsigned int)SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS,LB_GETHORIZONTALEXTENT,0,0) <= (strlen(temp1)*db_get_b(NULL, MODNAME, "WidthMultiplier", 5)))
- SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS,LB_SETHORIZONTALEXTENT,(strlen(temp1)*db_get_b(NULL, MODNAME, "WidthMultiplier", 5)),0);
+ if ((unsigned int)SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_GETHORIZONTALEXTENT, 0, 0) <= (strlen(temp1)*db_get_b(NULL, MODNAME, "WidthMultiplier", 5)))
+ SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_SETHORIZONTALEXTENT, (strlen(temp1)*db_get_b(NULL, MODNAME, "WidthMultiplier", 5)), 0);
}
fclose(filen);
}
@@ -145,20 +141,18 @@ void readFile(HWND hwnd)
INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_RELOADWINDOW:
+ char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
+ reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
{
- char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
- reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
- int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETCURSEL, 0 ,0);
+ int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS,LB_RESETCONTENT, 0,0);
- if (db_get_static(NULL, MODNAME, fn, string) )
- {
- if ( (!strncmp("http://", string, strlen("http://"))) || (!strncmp("https://", string, strlen("https://"))) )
- {
- SetDlgItemTextA(hwnd,IDC_URL, string);
- mir_snprintf(fn,SIZEOF(fn),"fn%d_timer", i);
+ SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_RESETCONTENT, 0, 0);
+ if (db_get_static(NULL, MODNAME, fn, string, SIZEOF(string))) {
+ if ((!strncmp("http://", string, strlen("http://"))) || (!strncmp("https://", string, strlen("https://")))) {
+ SetDlgItemTextA(hwnd, IDC_URL, string);
+ mir_snprintf(fn, SIZEOF(fn), "fn%d_timer", i);
SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(db_get_w(NULL, MODNAME, fn, 60), tmp, 10));
}
readFile(hwnd);
@@ -167,132 +161,112 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case WM_INITDIALOG:
- {
- SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
- TranslateDialogDefault(hwnd);
- }
+ SendMessage(hwnd, WM_RELOADWINDOW, 0, 0);
+ TranslateDialogDefault(hwnd);
return TRUE;
+
case WM_COMMAND:
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- switch(LOWORD(wParam)) {
+ switch (LOWORD(wParam)) {
case IDC_ADD_URL:
- {
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_URL)))
- {
- char text[512], url[512], fn[10] = "fn0", szFileName[MAX_PATH], temp[512];
- int i, timer;
- GetDlgItemTextA(hwnd,IDC_URL,text,SIZEOF(text));
- strcpy(url, text);
- if (!InternetDownloadFile(text))
- {
- for (i=0; ;i++)
- {
- mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- if (!db_get_static(NULL, MODNAME, fn, text))
- break;
- }
- mir_snprintf(szFileName, SIZEOF(szFileName), "%s\\plugins\\%s.html", getMimDir(temp), fn);
- if (savehtml(szFileName))
- {
- mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- db_set_s(NULL, MODNAME, fn, url);
- if (!GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER)))
- timer = 60;
- else
- {
- GetDlgItemTextA(hwnd,IDC_WWW_TIMER,text,SIZEOF(text));
- timer = atoi(text);
- }
- mir_snprintf(fn, SIZEOF(fn), "fn%d_timer", i);
- db_set_w(NULL, MODNAME, fn, (WORD)timer);
- SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_URL))) {
+ char text[512], url[512], fn[10] = "fn0", szFileName[MAX_PATH], temp[512];
+ int i, timer;
+ GetDlgItemTextA(hwnd, IDC_URL, text, SIZEOF(text));
+ strcpy(url, text);
+ if (!InternetDownloadFile(text)) {
+ for (i = 0;; i++) {
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
+ if (!db_get_static(NULL, MODNAME, fn, text, SIZEOF(text)))
+ break;
+ }
+ mir_snprintf(szFileName, SIZEOF(szFileName), "%s\\plugins\\%s.html", getMimDir(temp), fn);
+ if (savehtml(szFileName)) {
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
+ db_set_s(NULL, MODNAME, fn, url);
+ if (!GetWindowTextLength(GetDlgItem(hwnd, IDC_WWW_TIMER)))
+ timer = 60;
+ else {
+ GetDlgItemTextA(hwnd, IDC_WWW_TIMER, text, SIZEOF(text));
+ timer = atoi(text);
}
+ mir_snprintf(fn, SIZEOF(fn), "fn%d_timer", i);
+ db_set_w(NULL, MODNAME, fn, (WORD)timer);
+ SendMessage(hwnd, WM_RELOADWINDOW, 0, 0);
}
}
}
break;
+
case IDC_WWW_TIMER:
if (HIWORD(wParam) == EN_CHANGE)
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
case IDC_ADD_FILE:
- {
- int i, index;
- char file[MAX_PATH], fn[6];
- for (i=0; ;i++)
- {
- mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- if (!db_get_static(NULL, MODNAME, fn, file))
- break;
- }
- if (Openfile(file,1))
- {
- db_set_s(NULL, MODNAME, fn, file);
- index = SendDlgItemMessageA(hwnd, IDC_FILE_LIST, CB_ADDSTRING, 0, (LPARAM)file);
- SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_SETITEMDATA,index,(LPARAM)i);
- SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_SETCURSEL, index ,0);
- SetDlgItemTextA(hwnd, IDC_FN, _itoa(i, fn, 10));
- mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
- readFile(hwnd);
- }
-
+ int i, index;
+ char file[MAX_PATH], fn[6];
+ for (i = 0;; i++) {
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
+ if (!db_get_static(NULL, MODNAME, fn, file, SIZEOF(file)))
+ break;
+ }
+ if (Openfile(file, 1)) {
+ db_set_s(NULL, MODNAME, fn, file);
+ index = SendDlgItemMessageA(hwnd, IDC_FILE_LIST, CB_ADDSTRING, 0, (LPARAM)file);
+ SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_SETITEMDATA, index, (LPARAM)i);
+ SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_SETCURSEL, index, 0);
+ SetDlgItemTextA(hwnd, IDC_FN, _itoa(i, fn, 10));
+ mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
+ readFile(hwnd);
}
break;
+
case IDC_DEL_FILE:
+ char fn1[4], tmp[256];
{
- int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETCURSEL, 0,0),i= (int)SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETITEMDATA, index,0);
- char fn[6], fn1[4], tmp[256];
- int count = SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETCOUNT, 0,0) -1;
- if (index == count)
- {
+ int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0), i = (int)SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETITEMDATA, index, 0);
+ int count = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCOUNT, 0, 0) - 1;
+ if (index == count) {
mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
db_unset(NULL, MODNAME, fn);
- SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_DELETESTRING, index ,0);
- SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
+ SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_DELETESTRING, index, 0);
+ SendMessage(hwnd, WM_RELOADWINDOW, 0, 0);
if (!index) {
- SetDlgItemText(hwnd, IDC_FN,_T(""));
- SetDlgItemText(hwnd, IDC_FILE_CONTENTS,_T(""));
+ SetDlgItemText(hwnd, IDC_FN, _T(""));
+ SetDlgItemText(hwnd, IDC_FILE_CONTENTS, _T(""));
}
}
- else
- {
+ else {
mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- while (db_get_static(NULL, MODNAME, fn,tmp))
- {
- mir_snprintf(fn1, SIZEOF(fn1), "fn%d", i-1);
- db_set_s(NULL, MODNAME, fn1 , tmp);
+ while (db_get_static(NULL, MODNAME, fn, tmp, SIZEOF(tmp))) {
+ mir_snprintf(fn1, SIZEOF(fn1), "fn%d", i - 1);
+ db_set_s(NULL, MODNAME, fn1, tmp);
mir_snprintf(fn, SIZEOF(fn), "fn%d", ++i);
}
mir_snprintf(fn, SIZEOF(fn), "fn%d", --i);
db_unset(NULL, MODNAME, fn);
- SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_DELETESTRING, index ,0);
- SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
+ SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_DELETESTRING, index, 0);
+ SendMessage(hwnd, WM_RELOADWINDOW, 0, 0);
}
-
}
break;
-
case IDC_FILE_LIST:
- if (HIWORD(wParam) == CBN_SELCHANGE )
- {
- int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETCURSEL, 0,0);
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
char fn[20], tmp[MAX_PATH];
SetDlgItemTextA(hwnd, IDC_FN, _itoa(index, fn, 10));
mir_snprintf(fn, SIZEOF(fn), "fn%d", index);
- if (db_get_static(NULL, MODNAME, fn, tmp) )
- {
- if (!strncmp("http://", tmp, strlen("http://")) || !strncmp("https://", tmp, strlen("https://")))
- {
- SetDlgItemTextA(hwnd,IDC_URL, tmp);
+ if (db_get_static(NULL, MODNAME, fn, tmp, SIZEOF(tmp))) {
+ if (!strncmp("http://", tmp, strlen("http://")) || !strncmp("https://", tmp, strlen("https://"))) {
+ SetDlgItemTextA(hwnd, IDC_URL, tmp);
mir_snprintf(fn, SIZEOF(fn), "fn%d_timer", index);
SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(db_get_w(NULL, MODNAME, fn, 60), tmp, 10));
}
- else
- {
- SetDlgItemText(hwnd,IDC_URL, _T(""));
- SetDlgItemText(hwnd, IDC_WWW_TIMER,_T(""));
+ else {
+ SetDlgItemText(hwnd, IDC_URL, _T(""));
+ SetDlgItemText(hwnd, IDC_WWW_TIMER, _T(""));
}
readFile(hwnd);
}
@@ -304,23 +278,24 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return TRUE;
}
break;
+
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST,CB_GETCURSEL, 0 ,0);
+ int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
int timer;
char fn[MAX_PATH], string[1000];
mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- if (GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER))) {
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_WWW_TIMER))) {
TCHAR text[5];
- GetDlgItemText(hwnd,IDC_WWW_TIMER,text,SIZEOF(text));
+ GetDlgItemText(hwnd, IDC_WWW_TIMER, text, SIZEOF(text));
timer = _ttoi(text);
}
else timer = 60;
- if (db_get_static(NULL, MODNAME, fn, string))
+ if (db_get_static(NULL, MODNAME, fn, string, SIZEOF(string)))
if (!strncmp("http://", string, strlen("http://")) || !strncmp("https://", string, strlen("https://"))) {
mir_snprintf(fn, SIZEOF(fn), "fn%d_timer", i);
db_set_w(NULL, MODNAME, fn, (WORD)timer);
@@ -338,12 +313,12 @@ char* getMimDir(char* file)
{
GetModuleFileNameA(NULL, file, MAX_PATH);
- char *p1 = strrchr(file,'\\');
+ char *p1 = strrchr(file, '\\');
if (p1)
*p1 = '\0';
if (file[0] == '\\')
- file[strlen(file)-1] = '\0';
+ file[strlen(file) - 1] = '\0';
return file;
}
diff --git a/plugins/Non-IM Contact/src/http.cpp b/plugins/Non-IM Contact/src/http.cpp
index f67baf0391..7e8cdbe0cc 100644
--- a/plugins/Non-IM Contact/src/http.cpp
+++ b/plugins/Non-IM Contact/src/http.cpp
@@ -31,42 +31,41 @@ HANDLE hNetlibUser;
// szUrl = URL of the webpage to be retrieved
// return value = 0 for success, 1 or HTTP error code for failure
// global var used: szData, szInfo = containing the retrieved data
-int InternetDownloadFile (char *szUrl)
+
+int InternetDownloadFile(char *szUrl)
{
- NETLIBHTTPREQUEST nlhr={0};
+ NETLIBHTTPREQUEST nlhr = { 0 };
// initialize the netlib request
- nlhr.cbSize=sizeof(nlhr);
- nlhr.requestType=REQUEST_GET;
- nlhr.flags=NLHRF_DUMPASTEXT;
- nlhr.szUrl= szUrl;
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_DUMPASTEXT;
+ nlhr.szUrl = szUrl;
// change the header so the plugin is pretended to be IE 6 + WinXP
nlhr.headersCount++;
- nlhr.headers=(NETLIBHTTPHEADER*)malloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
- memcpy(nlhr.headers,nlhr.headers,sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
- nlhr.headers[nlhr.headersCount-1].szName="User-Agent";
- nlhr.headers[nlhr.headersCount-1].szValue=NETLIB_USER_AGENT;
+ nlhr.headers = (NETLIBHTTPHEADER*)malloc(sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
+ memcpy(nlhr.headers, nlhr.headers, sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
+ nlhr.headers[nlhr.headersCount - 1].szName = "User-Agent";
+ nlhr.headers[nlhr.headersCount - 1].szValue = NETLIB_USER_AGENT;
// download the page
- NETLIBHTTPREQUEST *nlhrReply=(NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION,(WPARAM)hNetlibUser,(LPARAM)&nlhr);
+ NETLIBHTTPREQUEST *nlhrReply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)hNetlibUser, (LPARAM)&nlhr);
if (nlhrReply) {
// return error code if the recieved code is neither 200 OK or 302 Moved
if (nlhrReply->resultCode != 200 && nlhrReply->resultCode != 302)
return nlhrReply->resultCode;
// if the recieved code is 200 OK
- else if (nlhrReply->resultCode == 200)
- {
+ else if (nlhrReply->resultCode == 200) {
// allocate memory and save the retrieved data
- szData = (char *)malloc(mir_strlen(nlhrReply->pData)+2);
+ szData = (char *)malloc(mir_strlen(nlhrReply->pData) + 2);
mir_strncpy(szData, nlhrReply->pData, mir_strlen(nlhrReply->pData));
}
// if the recieved code is 302 Moved, Found, etc
- else if (nlhrReply->resultCode == 302)
- { // page moved
+ else if (nlhrReply->resultCode == 302) { // page moved
int i;
// get the url for the new location and save it to szInfo
// look for the reply header "Location"
- for (i=0; i<nlhrReply->headersCount; i++) {
+ for (i = 0; i < nlhrReply->headersCount; i++) {
if (!mir_strcmp(nlhrReply->headers[i].szName, "Location")) {
szData = (char *)malloc(512);
// add "Moved/Location:" in front of the new URL for identification
@@ -75,7 +74,7 @@ int InternetDownloadFile (char *szUrl)
}
}
// log the new url into netlib log
- CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szData);
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)szData);
}
}
// if the data does not downloaded successfully (ie. disconnected), then return 1 as error code
@@ -83,7 +82,7 @@ int InternetDownloadFile (char *szUrl)
// make a copy of the retrieved data, then free the memory of the http reply
szInfo = szData;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
// the recieved data is empty, data was not recieved, so return an error code of 1
if (!mir_strcmp(szInfo, "")) return 1;
@@ -92,11 +91,12 @@ int InternetDownloadFile (char *szUrl)
//============ NETLIB INITIALIZATION ============
-void NetlibInit() {
- NETLIBUSER nlu={0};
- nlu.cbSize=sizeof(nlu);
- nlu.flags=NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION|NUF_TCHAR;
- nlu.szSettingsModule= MODNAME;
- nlu.ptszDescriptiveName= TranslateT("Non-IM Contacts");
- hNetlibUser=(HANDLE)CallService(MS_NETLIB_REGISTERUSER,0,(LPARAM)&nlu);
+void NetlibInit()
+{
+ NETLIBUSER nlu = { 0 };
+ nlu.cbSize = sizeof(nlu);
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_NOHTTPSOPTION | NUF_TCHAR;
+ nlu.szSettingsModule = MODNAME;
+ nlu.ptszDescriptiveName = TranslateT("Non-IM Contacts");
+ hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
}
diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp
index 6452e85981..679df4eb7a 100644
--- a/plugins/Non-IM Contact/src/main.cpp
+++ b/plugins/Non-IM Contact/src/main.cpp
@@ -24,23 +24,22 @@ PLUGININFOEX pluginInfoEx = {
{ 0x2e0d2ae3, 0xe123, 0x4607, {0x85, 0x39, 0xd4, 0x44, 0x8d, 0x67, 0x5d, 0xdb} }
};
-INT_PTR doubleClick(WPARAM wParam,LPARAM lParam)
+INT_PTR doubleClick(WPARAM wParam, LPARAM lParam)
{
char program[MAX_PATH], params[MAX_PATH];
int shellEXEerror = 0;
char* proto = GetContactProto(wParam);
if (proto && !strcmp(proto, MODNAME)) {
- if (GetKeyState(VK_CONTROL)&0x8000) // ctrl is pressed
+ if (GetKeyState(VK_CONTROL) & 0x8000) // ctrl is pressed
editContact(wParam, 0); // for later when i add a second double click setting
- else if (db_get_static(wParam, MODNAME, "Program", program) && strcmp(program, ""))
- {
- if (!db_get_static(wParam, MODNAME, "ProgramParams", params) )
+ else if (db_get_static(wParam, MODNAME, "Program", program, SIZEOF(program)) && strcmp(program, "")) {
+ if (!db_get_static(wParam, MODNAME, "ProgramParams", params, SIZEOF(params)))
strcpy(params, "");
if (strstr(program, "http://") || strstr(program, "https://"))
- CallService(MS_UTILS_OPENURL,OUF_NEWWINDOW,(LPARAM)program);
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)program);
else shellEXEerror = (int)ShellExecuteA(NULL, NULL, program, params, NULL, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :)
if (shellEXEerror == ERROR_FILE_NOT_FOUND || shellEXEerror == ERROR_PATH_NOT_FOUND)
- CallService(MS_UTILS_OPENURL,OUF_NEWWINDOW,(LPARAM)program);
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW, (LPARAM)program);
}
else editContact(wParam, 0);
return 1;
@@ -60,7 +59,7 @@ int LCStatus = ID_STATUS_OFFLINE;
// Returns : int
// Description : Called at very beginning of plugin
//=====================================================
-int NimcOptInit(WPARAM wParam,LPARAM)
+int NimcOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { sizeof(odp) };
odp.hInstance = hInst;
@@ -90,13 +89,13 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
// Description :
//=====================================================
-BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID lpvReserved)
{
- hInst=hinst;
+ hInst = hinst;
return TRUE;
}
-int ModulesLoaded(WPARAM wParam,LPARAM lParam)
+int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
NetlibInit();
return 0;
@@ -122,7 +121,7 @@ extern "C" __declspec(dllexport) int Load()
Icon_Register(hInst, LPGEN("Non-IM Contact"), icoList, SIZEOF(icoList));
HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick);
- HookEvent(ME_OPT_INITIALISE,NimcOptInit);
+ HookEvent(ME_OPT_INITIALISE, NimcOptInit);
HookEvent(ME_CLIST_STATUSMODECHANGE, SetLCStatus);
PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE, MODNAME, PROTOTYPE_VIRTUAL };
@@ -156,7 +155,7 @@ extern "C" __declspec(dllexport) int Load()
mi.pszService = "LoadFilesDlg";
Menu_AddMainMenuItem(&mi);
- if (db_get_b(NULL, MODNAME, "Beta",0)) {
+ if (db_get_b(NULL, MODNAME, "Beta", 0)) {
mi.position = 600090002;
mi.pszName = LPGEN("&Export all Non-IM Contacts");
mi.pszService = "ExportLCcontacts";
@@ -194,5 +193,6 @@ extern "C" __declspec(dllexport) int Load()
extern "C" __declspec(dllexport) int Unload(void)
{
+ killTimer();
return 0;
}
diff --git a/plugins/Non-IM Contact/src/namereplacing.cpp b/plugins/Non-IM Contact/src/namereplacing.cpp
index c9df0de9e1..e45120f8a7 100644
--- a/plugins/Non-IM Contact/src/namereplacing.cpp
+++ b/plugins/Non-IM Contact/src/namereplacing.cpp
@@ -23,12 +23,12 @@ int readFileIntoArray(int fileNumber, char *FileContents[])
// read the file into the FileContents array
// free this array before stringReplacer() returns
int i;
- for (i=0; fgets(temp, MAX_STRING_LENGTH-1, file); i++) {
- if (temp[strlen(temp)-1]=='\n')
- temp[strlen(temp)-1]='\0';
- else temp[strlen(temp)]='\0';
+ for (i = 0; fgets(temp, MAX_STRING_LENGTH - 1, file); i++) {
+ if (temp[strlen(temp) - 1] == '\n')
+ temp[strlen(temp) - 1] = '\0';
+ else temp[strlen(temp)] = '\0';
- FileContents[i] = (char*)malloc(strlen(temp)+1);
+ FileContents[i] = (char*)malloc(strlen(temp) + 1);
if (FileContents[i] == NULL) break;
strcpy(FileContents[i], temp);
}
@@ -41,22 +41,22 @@ int getNumber(const char* line)
int i;
return sscanf(line, "%d", &i) == 1 ? i : -1;
}
-
+
int findWordInString(const char* line, const char* string, int* lengthOfWord, int flag) /* flag = 0 %from, flag = 1 %until */
{
- unsigned int i, j=0;
- char word[64]="", OpenDivider[8], CloseDivider[8];
+ unsigned int i, j = 0;
+ char word[64] = "", OpenDivider[8], CloseDivider[8];
strncpy(OpenDivider, "(\"", sizeof(OpenDivider));
strncpy(CloseDivider, "\")", sizeof(CloseDivider));
/* get the word we r looking for */
if (!strncmp(string, OpenDivider, strlen(OpenDivider))) {
- for (i=2; strncmp(&string[i], CloseDivider, strlen(CloseDivider)); i++) {
+ for (i = 2; strncmp(&string[i], CloseDivider, strlen(CloseDivider)); i++) {
word[j] = string[i];
word[++j] = '\0';
}
}
- i=0;
- *lengthOfWord = (int)(strlen(word)+strlen(CloseDivider)+strlen(OpenDivider));
+ i = 0;
+ *lengthOfWord = (int)(strlen(word) + strlen(CloseDivider) + strlen(OpenDivider));
/* find the word in the line */
while (i < (strlen(line) - strlen(word))) {
if (!strncmp(&line[i], word, strlen(word))) {
@@ -68,7 +68,7 @@ int findWordInString(const char* line, const char* string, int* lengthOfWord, in
return -1;
}
-int findLine(char* FileContents[], const char* string, int linesInFile,int startLine, int *positionInOldString)
+int findLine(char* FileContents[], const char* string, int linesInFile, int startLine, int *positionInOldString)
{
char tmp[5];
int i = getNumber(&string[*positionInOldString]);
@@ -79,7 +79,7 @@ int findLine(char* FileContents[], const char* string, int linesInFile,int start
// check if its a number
if (i != -1) {
- *positionInOldString += (int)strlen(_itoa(i,tmp,10)) - 1;
+ *positionInOldString += (int)strlen(_itoa(i, tmp, 10)) - 1;
return i;
}
@@ -87,27 +87,27 @@ int findLine(char* FileContents[], const char* string, int linesInFile,int start
if (!strncmp(&string[*positionInOldString], "lastline(", strlen("lastline("))) {
*positionInOldString += (int)strlen("lastline(");
i = getNumber(&string[*positionInOldString]);
- if ( i != -1) {
- *positionInOldString += (int)strlen(_itoa(i,tmp,10));
- return linesInFile - (i+1);
+ if (i != -1) {
+ *positionInOldString += (int)strlen(_itoa(i, tmp, 10));
+ return linesInFile - (i + 1);
}
- (*positionInOldString)++;
+ (*positionInOldString)++;
return (linesInFile - 1);
}
// string
if (string[*positionInOldString] == '\"') {
char string2Find[256];
- int j=0;
+ int j = 0;
// get the word to find
- for (i=(*positionInOldString+1); strncmp(&string[i], "\")", 2); i++) {
+ for (i = (*positionInOldString + 1); strncmp(&string[i], "\")", 2); i++) {
string2Find[j] = string[i];
string2Find[++j] = '\0';
}
// find the word
- for (j=startLine; j<linesInFile;j++) {
+ for (j = startLine; j < linesInFile; j++) {
if (strstr(FileContents[j], string2Find)) {
i = j;
break;
@@ -115,22 +115,22 @@ int findLine(char* FileContents[], const char* string, int linesInFile,int start
i = -1;
}
*positionInOldString += (int)(strlen(string2Find) + strlen("\"\")"));
- if (i==-1) return i;
+ if (i == -1) return i;
// allow for a +- after the word to go up or down lines
if (string[*positionInOldString] == '+') {
*positionInOldString += 1;
j = getNumber(&string[*positionInOldString]);
if (j != -1) {
- *positionInOldString += (int)strlen(_itoa(j,tmp,10))-2;
- return i+j;
+ *positionInOldString += (int)strlen(_itoa(j, tmp, 10)) - 2;
+ return i + j;
}
}
else if (string[*positionInOldString] == '-') {
- *positionInOldString+=1;
+ *positionInOldString += 1;
j = getNumber(&string[*positionInOldString]);
if (j != -1) {
- *positionInOldString += (int)strlen(_itoa(j,tmp,10))-2;
- return i-j;
+ *positionInOldString += (int)strlen(_itoa(j, tmp, 10)) - 2;
+ return i - j;
}
}
else {
@@ -141,57 +141,57 @@ int findLine(char* FileContents[], const char* string, int linesInFile,int start
return -1;
}
-int findChar(char* FileContents[], const char* string, int linesInFile,int startLine, int *positionInOldString, int startChar, int startEnd) // 0=start, 1=end for startEnd
+int findChar(char* FileContents[], const char* string, int linesInFile, int startLine, int *positionInOldString, int startChar, int startEnd) // 0=start, 1=end for startEnd
{
char tmp[5];
int i = getNumber(&string[*positionInOldString]);
// check if its a number
if (i != -1) {
- *positionInOldString += (int)strlen(_itoa(i,tmp,10)) - 1;
+ *positionInOldString += (int)strlen(_itoa(i, tmp, 10)) - 1;
return i;
}
// string
if (string[*positionInOldString] == '\"') {
char string2Find[256];
- unsigned int j=0;
+ unsigned int j = 0;
// get the word to find
- for (i=(*positionInOldString+1); strncmp(&string[i], "\")", 2); i++) {
+ for (i = (*positionInOldString + 1); strncmp(&string[i], "\")", 2); i++) {
string2Find[j] = string[i];
string2Find[++j] = '\0';
}
// find the word
- for (j=0;j<strlen(FileContents[startLine]);j++)
+ for (j = 0; j < strlen(FileContents[startLine]); j++)
if (!strncmp(&FileContents[startLine][j], string2Find, strlen(string2Find)))
break;
- if (j==strlen(FileContents[startLine]))
+ if (j == strlen(FileContents[startLine]))
return -1;
- *positionInOldString += (int)strlen(string2Find)+1;
+ *positionInOldString += (int)strlen(string2Find) + 1;
return (startEnd) ? j : j + (int)strlen(string2Find);
}
-
+
// csv(
if (!strncmp(&string[*positionInOldString], "csv(", strlen("csv("))) {
char seperator;
- int j=0, k=startChar;
+ int j = 0, k = startChar;
*positionInOldString += (int)strlen("csv(");
if (!strncmp(&string[*positionInOldString], "tab", 3)) {
*positionInOldString += 3;
seperator = '\t';
}
- else if (!strncmp(&string[*positionInOldString], "space",5)) {
+ else if (!strncmp(&string[*positionInOldString], "space", 5)) {
*positionInOldString += 5;
seperator = ' ';
}
else {
- seperator =string[*positionInOldString];
+ seperator = string[*positionInOldString];
*positionInOldString += 1;
}
i = getNumber(&string[*positionInOldString]);
- if ( i == -1) return -1;
- *positionInOldString += (int)strlen(_itoa(i,tmp,10));
+ if (i == -1) return -1;
+ *positionInOldString += (int)strlen(_itoa(i, tmp, 10));
while (j < i) {
if (FileContents[startLine][k] == '\0') break;
if (FileContents[startLine][k] == seperator)
@@ -210,17 +210,16 @@ void checkStringForcompare(char *str)
char *A, *B, *X, *Y, *newStr = (char*)malloc(strlen(str)), *copyOfStr = _strdup(str);
unsigned int i, j = 0, s = (int)strlen(str);
newStr[0] = '\0';
- for (i=0; i<s; i++) {
+ for (i = 0; i < s; i++) {
if (!strncmp(&str[i], "compare(\"", strlen("compare(\""))) {
i += (int)strlen("compare(\"");
A = strtok(&copyOfStr[i], "\",\"");
B = strtok(NULL, "\",\"");
X = strtok(NULL, "\",\"");
Y = strtok(NULL, ",\")");
- j = Y - &copyOfStr[i] + (int)strlen(Y)+1;
- if (A && B && X && Y)
- {
- if (!strcmp(A,B))
+ j = Y - &copyOfStr[i] + (int)strlen(Y) + 1;
+ if (A && B && X && Y) {
+ if (!strcmp(A, B))
strcat(newStr, X);
else strcat(newStr, Y);
}
@@ -237,16 +236,16 @@ void checkStringForcompare(char *str)
// do save("A","B") A is DBVar name, B is value
void checkStringForSave(MCONTACT hContact, char* str)
{
- if (!strstr(str,"save(\"")) return;
- char *A,*B,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str);
- unsigned int i, j=0, s = (int)strlen(str);
+ if (!strstr(str, "save(\"")) return;
+ char *A, *B, *newStr = (char*)malloc(strlen(str)), *copyOfStr = _strdup(str);
+ unsigned int i, j = 0, s = (int)strlen(str);
newStr[0] = '\0';
- for (i=0; i<s; i++) {
- if (!strncmp(&str[i],"save(\"", strlen("save(\""))) {
+ for (i = 0; i < s; i++) {
+ if (!strncmp(&str[i], "save(\"", strlen("save(\""))) {
i += (int)strlen("save(\"");
A = strtok(&copyOfStr[i], "\",\"");
B = strtok(NULL, ",\")");
- j = B - &copyOfStr[i] + (int)strlen(B)+1;
+ j = B - &copyOfStr[i] + (int)strlen(B) + 1;
if (A && B)
db_set_s(hContact, MODNAME, A, B);
@@ -263,18 +262,18 @@ void checkStringForSave(MCONTACT hContact, char* str)
// do load("A") A is DBVar name
void checkStringForLoad(MCONTACT hContact, char* str)
{
- if (!strstr(str,"load(\"")) return;
- char *A,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str);
- unsigned int i, j=0, s = (int)strlen(str);
+ if (!strstr(str, "load(\"")) return;
+ char *A, *newStr = (char*)malloc(strlen(str)), *copyOfStr = _strdup(str);
+ unsigned int i, j = 0, s = (int)strlen(str);
newStr[0] = '\0';
- for (i=0; i<s; i++) {
+ for (i = 0; i < s; i++) {
if (!strncmp(&str[i], "load(\"", strlen("load(\""))) {
i += (int)strlen("load(\"");
A = strtok(&copyOfStr[i], "\")");
- j = A - &copyOfStr[i] + (int)strlen(A)+1;
+ j = A - &copyOfStr[i] + (int)strlen(A) + 1;
if (A) {
DBVARIANT dbv;
- if ( !db_get_s(hContact, MODNAME, A, &dbv)) {
+ if (!db_get_s(hContact, MODNAME, A, &dbv)) {
strcat(newStr, dbv.pszVal);
db_free(&dbv);
}
@@ -292,18 +291,18 @@ void checkStringForLoad(MCONTACT hContact, char* str)
// do saveN("A","B","C","D") A is module, B is setting, c is value, D is type 0/b 1/w 2/d 3/s
void checkStringForSaveN(char* str)
{
- if (!strstr(str,"saveN(\"")) return;
- char *A,*B,*C,*D,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str);
- unsigned int i, j=0, s = (int)strlen(str);
+ if (!strstr(str, "saveN(\"")) return;
+ char *A, *B, *C, *D, *newStr = (char*)malloc(strlen(str)), *copyOfStr = _strdup(str);
+ unsigned int i, j = 0, s = (int)strlen(str);
newStr[0] = '\0';
- for (i=0; i<s; i++) {
+ for (i = 0; i < s; i++) {
if (!strncmp(&str[i], "saveN(\"", strlen("saveN(\""))) {
i += (int)strlen("saveN(\"");
A = strtok(&copyOfStr[i], "\",\"");
B = strtok(NULL, ",\"");
C = strtok(NULL, ",\"");
D = strtok(NULL, ",\")");
- j = D - &copyOfStr[i] + (int)strlen(D)+1;
+ j = D - &copyOfStr[i] + (int)strlen(D) + 1;
if (A && B && C && D) {
switch (D[0]) {
case '0':
@@ -337,28 +336,28 @@ void checkStringForSaveN(char* str)
// do loadN("A","B") A is module, B is setting
void checkStringForLoadN(char* str)
{
- if (!strstr(str,"loadN(\"")) return;
- char *newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str), temp[32];
- unsigned int i, j=0, s = (int)strlen(str);
+ if (!strstr(str, "loadN(\"")) return;
+ char *newStr = (char*)malloc(strlen(str)), *copyOfStr = _strdup(str), temp[32];
+ unsigned int i, j = 0, s = (int)strlen(str);
newStr[0] = '\0';
- for (i=0; i<s; i++) {
+ for (i = 0; i < s; i++) {
if (!strncmp(&str[i], "loadN(\"", strlen("loadN(\""))) {
i += (int)strlen("loadN(\"");
char *A = strtok(&copyOfStr[i], "\",\"");
char *B = strtok(NULL, ",\")");
if (A && B) {
- j = B - &copyOfStr[i] + (int)strlen(B)+1;
+ j = B - &copyOfStr[i] + (int)strlen(B) + 1;
DBVARIANT dbv;
- if ( !db_get(NULL, A, B, &dbv)) {
+ if (!db_get(NULL, A, B, &dbv)) {
switch (dbv.type) {
case DBVT_BYTE:
- strcat(newStr,_itoa(dbv.bVal,temp,10));
+ strcat(newStr, _itoa(dbv.bVal, temp, 10));
break;
case DBVT_WORD:
- strcat(newStr,_itoa(dbv.wVal,temp,10));
+ strcat(newStr, _itoa(dbv.wVal, temp, 10));
break;
case DBVT_DWORD:
- strcat(newStr,_itoa(dbv.dVal,temp,10));
+ strcat(newStr, _itoa(dbv.dVal, temp, 10));
break;
case DBVT_ASCIIZ:
strcat(newStr, dbv.pszVal);
@@ -439,11 +438,11 @@ int lastChecked(char *newStr, const char *str)
// do icon(x) 0=offline, 1=online, 10=lunch
void checkIcon(MCONTACT hContact, char* string)
{
- char* str = strstr(string,"icon(");
+ char* str = strstr(string, "icon(");
if (str) {
- int icon = getNumber(str+5);
- if (icon >=0)
- db_set_w(hContact, MODNAME, "Status", (WORD)(ID_STATUS_OFFLINE+icon));
+ int icon = getNumber(str + 5);
+ if (icon >= 0)
+ db_set_w(hContact, MODNAME, "Status", (WORD)(ID_STATUS_OFFLINE + icon));
}
}
@@ -451,24 +450,21 @@ int stringReplacer(const char* oldString, char* newString, MCONTACT hContact)
{
char var_file[8];
int tempInt;
- int startLine = 0, endLine = 0, startChar=0, endChar = 0, wholeLine=-1, linesInFile;
+ int startLine = 0, endLine = 0, startChar = 0, endChar = 0, wholeLine = -1, linesInFile;
int positionInOldString = 0;
- char *fileContents[MAXLINES] = {NULL}, tempString[MAX_STRING_LENGTH];
+ char *fileContents[MAXLINES] = { NULL }, tempString[MAX_STRING_LENGTH];
// setup the variable names
strncpy(newString, "", sizeof(newString));
strncpy(var_file, "file(", sizeof(var_file));
- while ((positionInOldString < (int)strlen(oldString)) && (oldString[positionInOldString] != '\0'))
- {
+ while ((positionInOldString < (int)strlen(oldString)) && (oldString[positionInOldString] != '\0')) {
// load the file... must be first
- if (!strncmp(&oldString[positionInOldString], var_file, strlen(var_file)))
- {
+ if (!strncmp(&oldString[positionInOldString], var_file, strlen(var_file))) {
positionInOldString += (int)strlen(var_file);
// check if its a number
tempInt = getNumber(&oldString[positionInOldString]);
- if (tempInt == -1)
- {
+ if (tempInt == -1) {
// not a number so check vars..
// there are none yet
return ERROR_NO_FILE;
@@ -477,48 +473,44 @@ int stringReplacer(const char* oldString, char* newString, MCONTACT hContact)
linesInFile = readFileIntoArray(tempInt, fileContents);
if (linesInFile == 0)
return ERROR_NO_FILE;
- positionInOldString += (int)strlen(_itoa(tempInt, tempString,10)) + 1; // +1 for the closing )
+ positionInOldString += (int)strlen(_itoa(tempInt, tempString, 10)) + 1; // +1 for the closing )
// wholeline()
- if (!strncmp(&oldString[positionInOldString], "wholeline(line(", strlen("wholeline(line(")))
- {
+ if (!strncmp(&oldString[positionInOldString], "wholeline(line(", strlen("wholeline(line("))) {
positionInOldString += (int)strlen("wholeline(line(");
- tempInt = findLine(fileContents,oldString, linesInFile, startLine,&positionInOldString);
+ tempInt = findLine(fileContents, oldString, linesInFile, startLine, &positionInOldString);
if (tempInt == -1 || !fileContents[tempInt])
return ERROR_NO_LINE_AFTER_VAR_F;
wholeLine = tempInt;
positionInOldString += 3; // add 2 for the )) for wholeline(line())
}
- if (!strncmp(&oldString[positionInOldString], "start(", strlen("start(")))
- {
+ if (!strncmp(&oldString[positionInOldString], "start(", strlen("start("))) {
positionInOldString += (int)strlen("start(line(");
- tempInt = findLine(fileContents,oldString, linesInFile, startLine,&positionInOldString);
+ tempInt = findLine(fileContents, oldString, linesInFile, startLine, &positionInOldString);
if (tempInt == -1 || !fileContents[tempInt])
return ERROR_NO_LINE_AFTER_VAR_F;
- else
- {
- positionInOldString+=2;
+ else {
+ positionInOldString += 2;
startLine = tempInt;
if (!endChar)
endChar = (int)strlen(fileContents[startLine]);
- tempInt = findChar(fileContents,oldString, linesInFile, startLine,&positionInOldString, startChar,0);
+ tempInt = findChar(fileContents, oldString, linesInFile, startLine, &positionInOldString, startChar, 0);
if (tempInt == -1)
return ERROR_NO_LINE_AFTER_VAR_F;
startChar = tempInt;
}
positionInOldString += 2; // add 2 for the )) for start(line())
}
- if (!strncmp(&oldString[positionInOldString], "end(", strlen("end(")))
- {
+ if (!strncmp(&oldString[positionInOldString], "end(", strlen("end("))) {
positionInOldString += (int)strlen("end(line(");
- tempInt = findLine(fileContents,oldString, linesInFile, startLine,&positionInOldString);
+ tempInt = findLine(fileContents, oldString, linesInFile, startLine, &positionInOldString);
if (tempInt == -1 || !fileContents[tempInt])
return ERROR_NO_LINE_AFTER_VAR_F;
-
- positionInOldString+=2;
+
+ positionInOldString += 2;
endLine = tempInt;
- tempInt = findChar(fileContents,oldString, linesInFile, startLine,&positionInOldString, startChar,1);
+ tempInt = findChar(fileContents, oldString, linesInFile, startLine, &positionInOldString, startChar, 1);
if (tempInt == -1)
return ERROR_NO_LINE_AFTER_VAR_F;
endChar = tempInt;
@@ -529,19 +521,16 @@ int stringReplacer(const char* oldString, char* newString, MCONTACT hContact)
if (!strstr(oldString, "end(")) endLine = startLine;
// after all the options copy the line across and add 2 to positionInOldString for the file(print(....))
if (wholeLine >= 0) strcat(newString, fileContents[wholeLine]);
- else
- {
+ else {
// only copying from 1 line
if (startLine == endLine)
strncat(newString, &fileContents[startLine][startChar], endChar - startChar);
- else
- {
+ else {
int i;
// copy the whole first line from startChar
strcat(newString, &fileContents[startLine][startChar]);
// copy the middle lines across
- for (i=(startLine+1);i<endLine;i++)
- {
+ for (i = (startLine + 1); i < endLine; i++) {
strcat(newString, fileContents[i]);
}
// copy the last line untill endChar
@@ -550,36 +539,31 @@ int stringReplacer(const char* oldString, char* newString, MCONTACT hContact)
}
}
// filename()
- else if (!strncmp(&oldString[positionInOldString], "filename(", strlen("filename(")))
- {
+ else if (!strncmp(&oldString[positionInOldString], "filename(", strlen("filename("))) {
positionInOldString += (int)strlen("filename(");
tempInt = getNumber(&oldString[positionInOldString]);
- if (tempInt == -1)
- {
+ if (tempInt == -1) {
return ERROR_NO_FILE;
}
- else
- {
+ else {
mir_snprintf(tempString, SIZEOF(tempString), "fn%d", tempInt);
- if (db_get_static(NULL, MODNAME,tempString, tempString))
+ if (db_get_static(NULL, MODNAME, tempString, tempString, SIZEOF(tempString)))
strcat(newString, tempString);
else return ERROR_NO_FILE;
- positionInOldString += (int)strlen(_itoa(tempInt, tempString, 10))+1;
+ positionInOldString += (int)strlen(_itoa(tempInt, tempString, 10)) + 1;
}
}
// lastchecked(file(X))
- else if (!strncmp(&oldString[positionInOldString], "lastchecked(file(", strlen("lastchecked(file(")))
- {
+ else if (!strncmp(&oldString[positionInOldString], "lastchecked(file(", strlen("lastchecked(file("))) {
positionInOldString += lastChecked(newString, &oldString[positionInOldString]);
}
- else
- {
+ else {
strncat(newString, &oldString[positionInOldString], 1);
positionInOldString++;
}
}
// free the file strings
- for (tempInt=0; (fileContents[tempInt] != NULL) && (tempInt<MAXLINES); tempInt++)
+ for (tempInt = 0; (fileContents[tempInt] != NULL) && (tempInt < MAXLINES); tempInt++)
free(fileContents[tempInt]);
@@ -599,22 +583,21 @@ int stringReplacer(const char* oldString, char* newString, MCONTACT hContact)
void stripWhiteSpace(char* string)
{
- int i=0;
- while (string[i] != '\0')
- {
- if ( (string[i] == '\t') || (string[i] == '\r') || (string[i] == '\n') )
+ int i = 0;
+ while (string[i] != '\0') {
+ if ((string[i] == '\t') || (string[i] == '\r') || (string[i] == '\n'))
string[i] = ' ';
i++;
}
}
-void WriteSetting(MCONTACT hContact, char* module1, char* setting1 , char* module2, char* setting2)
+void WriteSetting(MCONTACT hContact, char* module1, char* setting1, char* module2, char* setting2)
{
char text[MAX_STRING_LENGTH], newString[MAX_STRING_LENGTH];
- int error = 0, status = GetLCStatus(0,0);
- if (db_get_static(hContact, module1, setting1, text)) {
+ int error = 0, status = GetLCStatus(0, 0);
+ if (db_get_static(hContact, module1, setting1, text, SIZEOF(text))) {
switch (stringReplacer(text, newString, hContact)) {
case ERROR_NO_LINE_AFTER_VAR_F:
- mir_snprintf(newString, SIZEOF(newString), Translate("%s - ERROR: no line specified or line not found (in %s)"),text, setting1);
+ mir_snprintf(newString, SIZEOF(newString), Translate("%s - ERROR: no line specified or line not found (in %s)"), text, setting1);
error = 1;
break;
case ERROR_LINE_NOT_READ:
@@ -634,14 +617,14 @@ void WriteSetting(MCONTACT hContact, char* module1, char* setting1 , char* modul
db_set_s(hContact, module2, setting2, newString);
}
else db_set_s(hContact, module2, setting2, "");
- if (!error)
- {
- if ( (status == ID_STATUS_ONLINE) || (status == ID_STATUS_AWAY) ||
- (status == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE) ) ||
- db_get_b(hContact, MODNAME ,"AlwaysVisible", 0)
- )
+
+ if (!error) {
+ if ((status == ID_STATUS_ONLINE) || (status == ID_STATUS_AWAY) ||
+ (status == db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE)) ||
+ db_get_b(hContact, MODNAME, "AlwaysVisible", 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);
+ else
+ db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE);
}
else db_set_w(hContact, MODNAME, "Status", ID_STATUS_OFFLINE);
}
@@ -654,14 +637,12 @@ void replaceAllStrings(MCONTACT hContact)
WriteSetting(hContact, MODNAME, "ProgramParamsString", MODNAME, "ProgramParams");
/* tooltips*/
WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes");
- if (db_get_static(hContact, MODNAME, "Program", tmp1) && db_get_static(hContact, MODNAME, "ProgramParams", tmp2)) {
+ if (db_get_static(hContact, MODNAME, "Program", tmp1, SIZEOF(tmp1)) && db_get_static(hContact, MODNAME, "ProgramParams", tmp2, SIZEOF(tmp2))) {
mir_snprintf(tmp3, SIZEOF(tmp3), "%s %s", tmp1, tmp2);
db_set_s(hContact, "UserInfo", "FirstName", tmp3);
}
- else if (db_get_static(hContact, MODNAME, "Program", tmp1))
- {
+ else if (db_get_static(hContact, MODNAME, "Program", tmp1, SIZEOF(tmp1))) {
db_set_s(hContact, "UserInfo", "FirstName", tmp1);
}
else db_set_s(hContact, "UserInfo", "FirstName", "");
}
-
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;
diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp
index fad1057038..9d81dbd70b 100644
--- a/plugins/Non-IM Contact/src/timer.cpp
+++ b/plugins/Non-IM Contact/src/timer.cpp
@@ -1,6 +1,6 @@
#include "commonheaders.h"
-UINT_PTR timerId;
+static UINT_PTR timerId = 0;
//=====================================================
// Name : timerProc
@@ -9,11 +9,11 @@ UINT_PTR timerId;
// Description : called when the timer interval occurs
//=====================================================
-void timerFunc(void *di)
+void timerFunc(void *di)
{
char text[512], fn[16], szFileName[MAX_PATH], temp[MAX_PATH];
- int timerCount = db_get_w(NULL, MODNAME, "timerCount",1)+1;
+ int timerCount = db_get_w(NULL, MODNAME, "timerCount", 1) + 1;
if (LCStatus == ID_STATUS_OFFLINE) {
killTimer();
@@ -22,9 +22,9 @@ void timerFunc(void *di)
db_set_w(NULL, MODNAME, "timerCount", (WORD)timerCount);
/* update the web pages*/
- for (int i=0; ;i++) {
+ for (int i = 0;; i++) {
mir_snprintf(fn, SIZEOF(fn), "fn%d", i);
- if (!db_get_static(NULL, MODNAME, fn, text))
+ if (!db_get_static(NULL, MODNAME, fn, text, SIZEOF(text)))
break;
if (!strncmp("http://", text, strlen("http://")) || !strncmp("https://", text, strlen("https://"))) {
@@ -43,7 +43,7 @@ void timerFunc(void *di)
for (MCONTACT hContact = db_find_first(MODNAME); hContact; hContact = db_find_next(hContact, MODNAME)) {
int timer = db_get_w(hContact, MODNAME, "Timer", 15);
if (timer && !(timerCount % timer))
- if (db_get_static(hContact, MODNAME, "Name", text))
+ if (db_get_static(hContact, MODNAME, "Name", text, SIZEOF(text)))
replaceAllStrings(hContact);
}
}
@@ -51,7 +51,7 @@ void timerFunc(void *di)
void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
{
// new thread for the timer...
- forkthread(timerFunc, 0, 0);
+ forkthread(timerFunc, 0, 0);
}
//=====================================================
@@ -76,7 +76,10 @@ int startTimer(int interval)
int killTimer()
{
- db_set_w(NULL, MODNAME, "timerCount",0);
- KillTimer(NULL,timerId);
+ if (timerId != 0) {
+ db_set_w(NULL, MODNAME, "timerCount", 0);
+ KillTimer(NULL, timerId);
+ timerId = 0;
+ }
return 0;
}