summaryrefslogtreecommitdiff
path: root/plugins/Non-IM Contact/src/contactinfo.cpp
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 /plugins/Non-IM Contact/src/contactinfo.cpp
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
Diffstat (limited to 'plugins/Non-IM Contact/src/contactinfo.cpp')
-rw-r--r--plugins/Non-IM Contact/src/contactinfo.cpp308
1 files changed, 147 insertions, 161 deletions
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);