summaryrefslogtreecommitdiff
path: root/plugins/!NotAdopted/Non-IM Contact/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/!NotAdopted/Non-IM Contact/files.c')
-rw-r--r--plugins/!NotAdopted/Non-IM Contact/files.c367
1 files changed, 0 insertions, 367 deletions
diff --git a/plugins/!NotAdopted/Non-IM Contact/files.c b/plugins/!NotAdopted/Non-IM Contact/files.c
deleted file mode 100644
index 00950db655..0000000000
--- a/plugins/!NotAdopted/Non-IM Contact/files.c
+++ /dev/null
@@ -1,367 +0,0 @@
-#include "commonheaders.h"
-
-int exportContacts(WPARAM wParam,LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char fn[MAX_PATH];
- FILE* file;
- char DBVar[1024];
- int tmp;
- if (Openfile(fn, 0))
- {
- if (tmp = MessageBox(0, "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.",modFullname, MB_YESNO) == IDYES)
- file = fopen(fn, "w");
- else file = fopen(fn, "a");
- if (file)
- {
- while (hContact)
- {
- const char* proto = (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
- if (proto && !strcmp(proto, modname))
- {
- if (DBGetContactSettingString(hContact, modname, "Name", DBVar))
- {
- fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
- if (DBGetContactSettingString(hContact, modname, "ProgramString", DBVar))
- fprintf(file, "ProgramString=%s\r\n", DBVar);
- if (DBGetContactSettingString(hContact, modname, "ProgramParamString", DBVar))
- fprintf(file, "ProgramParamString=%s\r\n", DBVar);
- if (DBGetContactSettingString(hContact, modname, "ToolTip", DBVar))
- fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
- if (DBGetContactSettingString(hContact, "CList", "Group", DBVar))
- fprintf(file, "Group=%s\r\n", DBVar);
- if (tmp = DBGetContactSettingWord(hContact, modname, "Icon", 40072))
- fprintf(file, "Icon=%d\r\n", tmp);
- if (tmp = DBGetContactSettingByte(hContact, modname, "UseTimer", 0))
- fprintf(file, "UseTimer=%d\r\n", tmp);
- if (tmp = DBGetContactSettingByte(hContact, modname, "Minutes", 1))
- fprintf(file, "Minutes=%d\r\n", tmp);
- if (tmp = DBGetContactSettingWord(hContact, modname, "Timer", 0))
- fprintf(file, "Timer=%d\r\n", tmp);
- fprintf(file, "[/Non-IM Contact]\r\n");
- }
- }
- hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0);
- }
- fclose(file);
- }
- else return 0;
- }
- else return 0;
- return 1;
-}
-
-
-int Openfile(char * outputFile, int saveOpen) //0=save, 1=open
-{
- OPENFILENAME ofn;
- char filename[MAX_PATH] = "";
- char *filter = "All Files\0*.*\0";
- int r;
- char title[16];
- if (saveOpen)
- strcpy(title, "Open file");
- else strcpy(title, "Save to file");
- ZeroMemory(&ofn, sizeof(ofn));
- ofn.lStructSize = 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.lpstrTitle = title;
- ofn.nMaxFile = MAX_PATH;
-
- if (saveOpen)
- r = GetOpenFileName((LPOPENFILENAME)&ofn);
- else r = GetSaveFileName((LPOPENFILENAME)&ofn);
- if (!r)
- return 0;
- lstrcpy(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++)
- {
- wsprintf(fn, "fn%d", i);
- if (DBGetContactSettingString(NULL, modname, fn, file))
- {
- index = SendMessage(fileList,CB_ADDSTRING,0, (LPARAM)(char*)file);
- SendMessage(fileList, CB_SETITEMDATA, index, (LPARAM)(int)i);
- SendMessage(fileList,CB_SETCURSEL, index,0);
- SetDlgItemText(GetParent(fileList), IDC_FN, itoa(i, fn, 10));
- /* add the file contents to the edit box */
- }
- else break;
- }
-}
-
-int savehtml(char* outFile)
-{
- FILE* file = fopen(outFile, "w");
- if (!file)
- {
- fclose(file);
- return 0;
- }
- fprintf(file, "%s", szInfo);
- fclose(file);
- return 1;
-}
-
-void readFile(HWND hwnd)
-{
- int lineNumber, fileLength=0, width=0;
- char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH], fn[8];
- FILE* filen;
- int fileNumber = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0,0);
- wsprintf(fn, "fn%d", fileNumber);
- if (!DBGetContactSettingString(NULL, modname, fn, szFileName))
- {
- msg(Translate("File couldn't be opened"),fn);
- return;
- }
-
- if ( (!strncmp("http://", szFileName, strlen("http://"))) || (!strncmp("https://", szFileName, strlen("https://"))) )
- wsprintf(szFileName,"%s\\plugins\\fn%d.html",getMimDir(temp), fileNumber);
-
- filen = fopen(szFileName,"r");
- if (!filen)
- {
- MessageBox(0, Translate("File couldn't be opened,2"), modFullname,MB_OK);
- return;
- }
- lineNumber = 0;
- SendMessage(GetDlgItem(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';
- wsprintf( temp1, Translate("line(%-3d) = | %s"), lineNumber, temp);
- SendMessage(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_ADDSTRING,0,(LPARAM)(char*)temp1);
- lineNumber++;
- fileLength++;
- if ((unsigned int)SendMessage(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_GETHORIZONTALEXTENT,0,0) <= (strlen(temp1)*DBGetContactSettingByte(NULL, modname, "WidthMultiplier", 5)))
- SendMessage(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_SETHORIZONTALEXTENT,(strlen(temp1)*DBGetContactSettingByte(NULL, modname, "WidthMultiplier", 5)),0);
- }
- fclose(filen);
-
- return ;
-}
-#define WM_RELOADWINDOW (WM_USER+11)
-BOOL CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
-{
- switch(msg) {
- case WM_RELOADWINDOW:
- {
- int i;
- char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
- reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
- i = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0 ,0);
- wsprintf(fn , "fn%d", i);
- SendMessage(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_RESETCONTENT, 0,0);
- if (DBGetContactSettingString(NULL, modname, fn, string) )
- {
- if ( (!strncmp("http://", string, strlen("http://"))) || (!strncmp("https://", string, strlen("https://"))) )
- {
- SetDlgItemText(hwnd,IDC_URL, string);
- SetDlgItemText(hwnd, IDC_WWW_TIMER, itoa(DBGetContactSettingWord(NULL, modname, strcat(fn, "_timer"), 60), tmp, 10));
- }
- readFile(hwnd);
- }
- }
- break;
-
- case WM_INITDIALOG:
- {
- SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
- TranslateDialogDefault(hwnd);
- }
- return TRUE;
- case WM_COMMAND:
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- 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;
- GetDlgItemText(hwnd,IDC_URL,text,sizeof(text));
- strcpy(url, text);
- if (!InternetDownloadFile(text))
- {
- for (i=0; ;i++)
- {
- wsprintf(fn, "fn%d", i);
- if (!DBGetContactSettingString(NULL, modname, fn, text))
- break;
- }
- wsprintf(szFileName,"%s\\plugins\\%s.html",getMimDir(temp), fn);
- if (savehtml(szFileName))
- {
- wsprintf(fn, "fn%d", i);
- DBWriteContactSettingString(NULL, modname, fn, url);
- if(!GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER)))
- timer = 60;
- else
- {
- GetDlgItemText(hwnd,IDC_WWW_TIMER,text,sizeof(text));
- timer = atoi(text);
- }
- DBWriteContactSettingWord(NULL, modname, strcat(fn, "_timer"), (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);
- break;
- case IDC_ADD_FILE:
- {
- int i, index;
- char file[MAX_PATH], fn[6];
- for (i=0; ;i++)
- {
- wsprintf(fn, "fn%d", i);
- if (!DBGetContactSettingString(NULL, modname, fn, file))
- break;
- }
- if (Openfile(file,1))
- {
- DBWriteContactSettingString(NULL, modname, fn, file);
- index = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_ADDSTRING,0,(LPARAM)(char*)file);
- SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_SETITEMDATA,index,(LPARAM)(int)i);
- SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_SETCURSEL, index ,0);
- SetDlgItemText(hwnd, IDC_FN, itoa(i, fn, 10));
- wsprintf(fn , "fn%d", index);
- readFile(hwnd);
- }
-
- }
- break;
- case IDC_DEL_FILE:
- {
- int index = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0,0),i= (int)SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETITEMDATA, index,0);
- char fn[6], fn1[4], tmp[256];
- int count = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCOUNT, 0,0) -1;
- if (index == count)
- {
- wsprintf(fn, "fn%d", index);
- DBDeleteContactSetting(NULL, modname, fn);
- SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_DELETESTRING, index ,0);
- SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
- if (!index)
- {
- SetDlgItemText(hwnd, IDC_FN,"");
- SetDlgItemText(hwnd, IDC_FILE_CONTENTS,"");
- }
-
- }
- else
- {
- wsprintf(fn, "fn%d", i);
- while (DBGetContactSettingString(NULL, modname, fn,tmp))
- {
- wsprintf(fn1, "fn%d", i-1);
- DBWriteContactSettingString(NULL, modname, fn1 , tmp);
- wsprintf(fn, "fn%d", ++i);
- }
- wsprintf(fn, "fn%d", --i);
- DBDeleteContactSetting(NULL, modname, fn);
- SendMessage(GetDlgItem(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 = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0,0);
- char fn[6], tmp[MAX_PATH];
- SetDlgItemText(hwnd, IDC_FN, itoa(index, fn, 10));
- wsprintf(fn, "fn%d", index);
- if (DBGetContactSettingString(NULL, modname, fn, tmp) )
- {
- if (!strncmp("http://", tmp, strlen("http://")) || !strncmp("https://", tmp, strlen("https://")))
- {
- SetDlgItemText(hwnd,IDC_URL, tmp);
- SetDlgItemText(hwnd, IDC_WWW_TIMER, itoa(DBGetContactSettingWord(NULL, modname, strcat(fn, "_timer"), 60), tmp, 10));
- }
- else
- {
- SetDlgItemText(hwnd,IDC_URL, "");
- SetDlgItemText(hwnd, IDC_WWW_TIMER,"");
- }
- readFile(hwnd);
- }
- }
- break;
- case IDCANCEL:
- DestroyWindow(hwnd);
- break;
- return TRUE;
- }
- break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- int i = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0 ,0);
- int timer;
- char fn[MAX_PATH], string[1000];;
- wsprintf(fn , "fn%d", i);
- if(GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER)))
- {
- char text[5];
- GetDlgItemText(hwnd,IDC_WWW_TIMER,text,sizeof(text));
- timer = atoi(text);
- }
- else timer = 60;
- if (DBGetContactSettingString(NULL, modname, fn, string) )
- {
- if (!strncmp("http://", string, strlen("http://")) || !strncmp("https://", string, strlen("https://")))
- DBWriteContactSettingWord(NULL, modname, strcat(fn, "_timer"), (WORD)timer);
- }
-
- }
- return TRUE;
- }
- break;
- }
- break;
- }
- return FALSE;
-}
-
-char* getMimDir(char* file)
-{
- char *p1;
- GetModuleFileName(NULL,file, MAX_PATH);
-
- p1 = strrchr(file,'\\');
- if (p1)
- *p1 = '\0';
- if (file[0] == '\\')
- {
- file[strlen(file)-1] = '\0';
- }
- return file;
-}