diff options
Diffstat (limited to 'plugins/Non-IM Contact/src')
-rw-r--r-- | plugins/Non-IM Contact/src/Version.h | 14 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/commonheaders.h | 128 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/contactinfo.cpp | 707 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/dialog.cpp | 368 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/files.cpp | 350 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/http.cpp | 103 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/main.cpp | 199 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/namereplacing.cpp | 662 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/resource.h | 77 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/services.cpp | 127 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/stdafx.cpp | 18 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/timer.cpp | 84 |
12 files changed, 2837 insertions, 0 deletions
diff --git a/plugins/Non-IM Contact/src/Version.h b/plugins/Non-IM Contact/src/Version.h new file mode 100644 index 0000000000..ae84abc336 --- /dev/null +++ b/plugins/Non-IM Contact/src/Version.h @@ -0,0 +1,14 @@ +#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 6
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 1
+
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+
+#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 __AUTHOR "Jonathan Gordon"
+#define __AUTHOREMAIL "ICQ 98791178, MSN jonnog@hotmail.com"
+#define __AUTHORWEB "http://miranda-ng.org/"
+#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 new file mode 100644 index 0000000000..a512a40b06 --- /dev/null +++ b/plugins/Non-IM Contact/src/commonheaders.h @@ -0,0 +1,128 @@ +//=====================================================
+// Includes (yea why not include lots of stuff :p )
+//=====================================================
+#ifndef COMMONHEADERS
+#define COMMONHEADERS
+
+#define _CRT_SECURE_NO_WARNINGS
+
+#include <windows.h>
+#include <commctrl.h>
+#include <winsock.h>
+#include <shlobj.h>
+
+#include <stdio.h>
+#include <time.h>
+#include <stddef.h>
+#include <process.h>
+#include <string.h>
+
+struct DLGTEMPLATEEX
+{
+ WORD dlgVer;
+ WORD signature;
+ DWORD helpID;
+ DWORD exStyle;
+ DWORD style;
+ WORD cDlgItems;
+ short x;
+ short y;
+ short cx;
+ short cy;
+};
+
+#include <newpluginapi.h>
+#include <m_clist.h>
+#include <m_clui.h>
+#include <m_skin.h>
+#include <m_langpack.h>
+#include <m_protomod.h>
+#include <m_database.h>
+#include <m_system.h>
+#include <m_protocols.h>
+#include <m_userinfo.h>
+#include <m_options.h>
+#include <m_protosvc.h>
+#include <m_utils.h>
+#include <m_ignore.h>
+#include <m_clc.h>
+#include <m_netlib.h>
+#include <win2k.h>
+
+#include "resource.h"
+
+//=======================================================
+// Definitions
+//=======================================================
+#define MODNAME "NIM_Contact"
+#define modFullname "Non-IM Contact"
+#define MAXLINES 10000
+#define MAX_STRING_LENGTH 10000
+#define LINE_LENGTH 10000
+#define msg(a,b) MessageBoxA(0,a,b,MB_OK);
+#define TIMER (db_get_w(NULL, MODNAME, "Timer", 1) * 1000)
+/* ERROR VALUES */
+#define ERROR_NO_LINE_AFTER_VAR_F -1
+#define ERROR_LINE_NOT_READ -2
+#define ERROR_NO_FILE -3
+
+//=======================================================
+// Defines
+//=======================================================
+//General
+extern HINSTANCE hInst;
+extern int LCStatus;
+static HANDLE hWindowList=NULL;
+
+//Services.c
+INT_PTR GetLCCaps(WPARAM wParam,LPARAM lParam);
+INT_PTR GetLCName(WPARAM wParam,LPARAM lParam);
+INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam);
+int SetLCStatus(WPARAM wParam,LPARAM lParam);
+INT_PTR GetLCStatus(WPARAM wParam,LPARAM lParam);
+
+// dialog.c
+INT_PTR addContact(WPARAM wParam,LPARAM lParam) ;
+INT_PTR editContact(WPARAM wParam,LPARAM lParam);
+INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR testStringReplacer(WPARAM wParam, LPARAM lParam);
+INT_PTR LoadFilesDlg(WPARAM wParam, LPARAM lParam);
+
+
+// files.c
+int Openfile(char* outputFile, int saveOpen);
+INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+int savehtml(char* outFile);
+char* getMimDir(char* file);
+INT_PTR exportContacts(WPARAM wParam,LPARAM lParam) ;
+
+// contactinfo.c
+INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+void ExportContact(HANDLE hContact);
+INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam);
+
+// stringreplacer.c
+int stringReplacer(const char* oldString, char* newString, HANDLE hContact);
+void replaceAllStrings(HANDLE hContact);
+void WriteSetting(HANDLE hContact, char* module1, char* setting1 , char* module12, char* setting2);
+
+//timer.c
+extern UINT_PTR timerId;
+void CALLBACK timerProc();
+int startTimer(int interval);
+int killTimer();
+
+// http.c
+void NetlibInit();
+int InternetDownloadFile (CHAR *szUrl);
+extern char *szInfo;
+extern char *szData;
+extern HANDLE hNetlibUser;
+
+int db_get_static(HANDLE hContact, const char *moduleName, const char *fn, char *buf);
+
+#endif
+
+#pragma comment(lib,"comctl32.lib")
diff --git a/plugins/Non-IM Contact/src/contactinfo.cpp b/plugins/Non-IM Contact/src/contactinfo.cpp new file mode 100644 index 0000000000..7b79a6c6f2 --- /dev/null +++ b/plugins/Non-IM Contact/src/contactinfo.cpp @@ -0,0 +1,707 @@ +#include "commonheaders.h"
+
+INT_PTR CALLBACK DlgProcContactInfo(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ {
+ HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
+ char name[2048];
+ TranslateDialogDefault(hwnd);
+ SetWindowLong(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
+
+ if (!db_get_static(hContact, MODNAME, "Name", name)) break;
+ SetDlgItemTextA(hwnd, IDC_DISPLAY_NAME, name);
+ if (!db_get_static(hContact, MODNAME, "ToolTip", name)) break;
+ SetDlgItemTextA(hwnd, IDC_TOOLTIP, name);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ return TRUE;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ if (GetWindowTextLength(GetDlgItem(hwnd,IDC_DISPLAY_NAME))) {
+ char text[512];
+ GetDlgItemTextA(hwnd,IDC_DISPLAY_NAME,text,sizeof(text));
+ db_set_s(hContact, MODNAME, "Name", text);
+ WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick");
+ }
+ else {
+ db_unset(hContact, MODNAME, "Name");
+ db_unset(hContact, MODNAME, "Nick");
+ }
+
+ if (GetWindowTextLength(GetDlgItem(hwnd,IDC_TOOLTIP))) {
+ char text[2048];
+ GetDlgItemTextA(hwnd,IDC_TOOLTIP,text,sizeof(text));
+ db_set_s(hContact, MODNAME, "ToolTip", text);
+ WriteSetting(hContact, MODNAME, "ToolTip", "UserInfo", "MyNotes");
+ }
+ else {
+ db_unset(hContact, MODNAME, "ToolTip");
+ db_unset(hContact, "UserInfo", "MyNotes");
+ }
+ }
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static WNDPROC g_PrevBtnWndProc = 0;
+
+LRESULT CALLBACK ButtWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT res = CallWindowProc(g_PrevBtnWndProc, hWnd, message, wParam, lParam);
+ if (WM_PAINT == message) {
+ RECT rc;
+ HDC dc = GetDC(hWnd);
+ BOOL isPressed = BST_CHECKED == SendMessage(hWnd, BM_GETCHECK, 0, 0);
+
+ GetClientRect(hWnd, &rc);
+ rc.left += (rc.right - rc.left - 16) / 2;
+ rc.top += (rc.bottom - rc.top - 16) / 2;
+ if (isPressed)
+ OffsetRect(&rc, 1, 1);
+ DrawIconEx(dc, rc.left, rc.top, (HICON)GetWindowLong(hWnd, GWLP_USERDATA),
+ 16, 16, 0, 0, DI_NORMAL);
+ ReleaseDC(hWnd, dc);
+ }
+
+ return res;
+}
+
+void checkGroups(char* group)
+{
+ int i;
+ char str[50], name[256];
+ DBVARIANT dbv;
+
+ if (lstrlenA(group) < 1)
+ return;
+
+ for (i = 0;; i++) {
+ _itoa(i, str, 10);
+ if (DBGetContactSetting(NULL, "CListGroups", str, &dbv))
+ break;
+
+ if (dbv.type == DBVT_ASCIIZ) {
+ if (dbv.pszVal[0] != '\0' && !lstrcmpiA(dbv.pszVal + 1, group)) {
+ db_free(&dbv);
+ return;
+ }
+
+ db_free(&dbv);
+ }
+ }
+ name[0] = 1 | GROUPF_EXPANDED;
+ strncpy(name + 1, group, sizeof(name) - 1);
+ name[strlen(group) + 1] = '\0';
+ db_set_s(NULL, "CListGroups", str, name);
+ CallService(MS_CLUI_GROUPADDED, i + 1, 0);
+}
+
+int BrowseForFolder(HWND hwnd,char *szPath)
+{
+ int result=0;
+
+ if (SUCCEEDED(OleInitialize(NULL))) {
+ LPMALLOC pMalloc;
+ if (SUCCEEDED(CoGetMalloc(1,&pMalloc))) {
+ mir_ptr<TCHAR> tszPath( mir_a2t(szPath));
+ BROWSEINFO bi={0};
+ bi.hwndOwner = hwnd;
+ bi.pszDisplayName = tszPath;
+ bi.lpszTitle = TranslateT("Select Folder");
+ bi.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS; // Use this combo instead of BIF_USENEWUI
+ bi.lParam = (LPARAM)szPath;
+
+ ITEMIDLIST *pidlResult = SHBrowseForFolder(&bi);
+ if (pidlResult) {
+ SHGetPathFromIDListA(pidlResult, szPath);
+ lstrcatA(szPath,"\\");
+ result = 1;
+ }
+ pMalloc->Free(pidlResult);
+ pMalloc->Release();
+ }
+ OleUninitialize();
+ }
+ return result;
+}
+
+INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ {
+ int i = 0;
+ DBVARIANT dbv;
+ char string[512];
+ HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
+ TranslateDialogDefault(hwnd);
+ SetWindowLong(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
+ if (!hContact)
+ break;
+
+ /* link*/
+ if (db_get_static(hContact, MODNAME, "ProgramString", string))
+ SetDlgItemTextA(hwnd, IDC_LINK, string);
+ if (db_get_static(hContact, MODNAME, "ProgramParamsString", string))
+ SetDlgItemTextA(hwnd, IDC_PARAMS, string);
+ /* group*/
+ while (i != -1)
+ {
+ char str[3], name[256];
+ wsprintfA(str, "%d", i);
+ if (!DBGetContactSetting(NULL, "CListGroups", str, &dbv))
+ {
+ lstrcpynA(name,dbv.pszVal+1,sizeof(name));
+ SendMessage(GetDlgItem(hwnd, IDC_GROUP), CB_INSERTSTRING,0, (LPARAM)name);
+ i++;
+ }
+ else i = -1;
+ }
+ if (!DBGetContactSetting(hContact, "CList", "Group", &dbv))
+ SetDlgItemTextA(hwnd, IDC_GROUP, dbv.pszVal);
+
+ /* icons */
+ CheckRadioButton(hwnd, 40072, 40080, db_get_w(hContact, MODNAME, "Icon", ID_STATUS_ONLINE));
+ SetWindowLong(GetDlgItem(hwnd, CHK_ONLINE), GWLP_USERDATA, (LONG)LoadSkinnedProtoIcon(MODNAME, ID_STATUS_ONLINE));
+ g_PrevBtnWndProc = (WNDPROC)SetWindowLong(GetDlgItem(hwnd, CHK_ONLINE), GWLP_WNDPROC, (LONG)ButtWndProc);
+ for (i = ID_STATUS_ONLINE; i<=ID_STATUS_OUTTOLUNCH; i++) {
+ SetWindowLong(GetDlgItem(hwnd, i), GWLP_USERDATA, (LONG)LoadSkinnedProtoIcon(MODNAME, i));
+ SetWindowLong(GetDlgItem(hwnd, i), GWLP_WNDPROC, (LONG)ButtWndProc);
+ }
+ db_free(&dbv);
+ /* timer */
+ CheckDlgButton(hwnd, CHK_USE_TIMER, db_get_b(hContact, MODNAME ,"UseTimer", 0));
+ if (db_get_w(hContact, MODNAME ,"Timer", 15)) {
+ CheckDlgButton(hwnd, CHK_USE_TIMER,1);
+ EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 1);
+ SetDlgItemTextA(hwnd, IDC_TIMER, _itoa(db_get_w(hContact, MODNAME ,"Timer", 15), string, 10));
+ if (!db_get_w(NULL, MODNAME ,"Timer", 1))
+ SetDlgItemTextA(hwnd,IDC_TIMER_INTERVAL_MSG, "Non-IM Contact protocol timer is Disabled");
+ else {
+ _snprintf(string, sizeof(string), "Timer intervals... Non-IM Contact Protocol timer is %d seconds",db_get_w(NULL, MODNAME ,"Timer", 1));
+ SetDlgItemTextA(hwnd,IDC_TIMER_INTERVAL_MSG, string);
+ }
+ }
+ /* always visible */
+ if (db_get_b(hContact, MODNAME ,"AlwaysVisible", 0)) {
+ CheckDlgButton(hwnd, IDC_ALWAYS_VISIBLE, 1);
+ EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),1);
+ CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME ,"VisibleUnlessOffline", 1));
+ }
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ switch(LOWORD(wParam)) {
+ case IDC_ALWAYS_VISIBLE:
+ if (IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE)) {
+ HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),1);
+ CheckDlgButton(hwnd, IDC_VISIBLE_UNLESS_OFFLINE, db_get_b(hContact, MODNAME ,"VisibleUnlessOffline", 1));
+ }
+ else EnableWindow(GetDlgItem(hwnd, IDC_VISIBLE_UNLESS_OFFLINE),0);
+ break;
+
+ case CHK_USE_TIMER:
+ if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER)) {
+ HANDLE hContact = (HANDLE)GetWindowLong(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));
+ }
+ else EnableWindow(GetDlgItem(hwnd, IDC_TIMER), 0);
+ break;
+
+ case IDC_OPEN_FILE:
+ {
+ char szFileName[512];
+ if ( Openfile(szFileName,1))
+ SetDlgItemTextA(hwnd, IDC_LINK, szFileName);
+ }
+ break;
+
+ case IDC_OPEN_FOLDER:
+ {
+ char szFileName[512];
+ if (BrowseForFolder(hwnd, szFileName)) {
+ wsprintfA(szFileName, "%s ,/e", szFileName);
+ SetDlgItemTextA(hwnd, IDC_LINK, "explorer.exe");
+ SetDlgItemTextA(hwnd, IDC_PARAMS, szFileName);
+ }
+ }
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ int status = GetLCStatus(0,0);
+ HANDLE hContact = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA);
+ int i;
+ if (GetWindowTextLength(GetDlgItem(hwnd,IDC_LINK)))
+ {
+ char text[512];
+ 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)))
+ {
+ char text[512];
+ 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)))
+ {
+ char text[512];
+ GetDlgItemTextA(hwnd,IDC_GROUP,text,sizeof(text));
+ checkGroups(text);
+ db_set_s(hContact, "CList", "Group", text);
+ }
+ else db_unset(hContact, "CList", "Group");
+ for (i = ID_STATUS_ONLINE; i<=ID_STATUS_OUTTOLUNCH; i++)
+ {
+ if (IsDlgButtonChecked(hwnd, i))
+ db_set_w(hContact, MODNAME, "Icon", (WORD)i);
+ }
+ /* set correct status */
+ if ( (status == ID_STATUS_ONLINE) || (status == ID_STATUS_AWAY) ||
+ (status == 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);
+
+ if (IsDlgButtonChecked(hwnd, CHK_USE_TIMER))
+ {
+ if (GetWindowTextLength(GetDlgItem(hwnd,IDC_TIMER)))
+ {
+ char text[512];
+ GetDlgItemTextA(hwnd,IDC_TIMER,text,sizeof(text));
+ db_set_w(hContact, MODNAME, "Timer", (WORD)atoi(text));
+ }
+ else db_set_w(hContact, MODNAME, "Timer", 15);
+ }
+ else db_set_w(hContact, MODNAME, "Timer", 0);
+ // always visible
+ db_set_b(hContact, MODNAME, "AlwaysVisible", (BYTE)IsDlgButtonChecked(hwnd, IDC_ALWAYS_VISIBLE));
+ db_set_b(hContact, MODNAME, "VisibleUnlessOffline", (BYTE)IsDlgButtonChecked(hwnd, IDC_VISIBLE_UNLESS_OFFLINE));
+ }
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+char* copyReplaceString(char* oldStr, char* newStr, char* findStr, char* replaceWithStr)
+{
+ int i=0;
+ while (oldStr[i] != '\0') {
+ // msg(&oldStr[i],"");
+ if (!strncmp(&oldStr[i],findStr, strlen(findStr))) {
+ strcat(newStr,replaceWithStr);
+ i += (int)strlen(findStr);
+ }
+ else {
+ strncat(newStr,&oldStr[i],1);
+ i++;
+ }
+ }
+ return newStr;
+}
+
+#define MAX_REPLACES 15
+
+INT_PTR CALLBACK DlgProcCopy(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ {
+ HANDLE hContact = (HANDLE)((PROPSHEETPAGE*)lParam)->lParam;
+ TranslateDialogDefault(hwnd);
+ SetWindowLong(hwnd, GWLP_USERDATA, (LPARAM)(HANDLE)hContact);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ switch(LOWORD(wParam)) {
+ case IDC_EXPORT:
+ ExportContact((HANDLE)GetWindowLong(hwnd, GWLP_USERDATA));
+ break;
+
+ case IDC_DOIT:
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE))) {
+ char *replace = (char*)malloc(GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) +1);
+ char newString[MAX_REPLACES][512], oldString[MAX_REPLACES][512];
+ char dbVar1[2000], dbVar2[2000];
+ int i=0,j=0, k=0;
+ char *string = oldString[k];
+ HANDLE hContact1 = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA), hContact2;
+ GetDlgItemTextA(hwnd, IDC_STRING_REPLACE, replace, GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING_REPLACE)) +1);
+ if (db_get_static(hContact1, MODNAME, "Name", dbVar1)) {
+ // get the list of replace strings
+ while (replace[i] != '\0') {
+ if (replace[i] == ',') {
+ string = newString[k];
+ j=0;
+ }
+ else if (!strncmp(&replace[i], "\r\n",2)) {
+ if (string == newString[k])
+ k--;
+ if (k = MAX_REPLACES) break;
+ string = oldString[++k];
+ i+=2;
+ continue;
+ }
+ else {
+ string[j] = replace[i];
+ string[++j] = '\0';
+ }
+ i++;
+ }
+ hContact2 =(HANDLE) 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] );
+
+ db_set_s(hContact2, MODNAME, "Name", dbVar2);
+ // copy the ProgramString
+ if (db_get_static(hContact1, MODNAME, "ProgramString",dbVar1)) {
+ strcpy(dbVar2, "");
+ 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)) {
+ strcpy(dbVar2, "");
+ 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)) {
+ strcpy(dbVar2, "");
+ 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)) {
+ strcpy(dbVar2, "");
+ for (i=0;i<=k;i++)
+ copyReplaceString(dbVar1, dbVar2, oldString[i],newString[i] );
+
+ db_set_s(hContact2, MODNAME, "ToolTip", dbVar2);
+ }
+ // timer
+ db_set_b(hContact2, MODNAME, "UseTimer", (BYTE)db_get_b(hContact1, MODNAME, "UseTimer", 0));
+ db_set_b(hContact2, MODNAME, "Minutes", (BYTE)db_get_b(hContact1, MODNAME, "Minutes", 0));
+ db_set_w(hContact2, MODNAME, "Timer", (WORD)db_get_w(hContact1, MODNAME, "Timer", 0));
+ //icon
+ db_set_w(hContact2, MODNAME, "Icon", (WORD)db_get_w(hContact1, MODNAME, "Icon", 40072));
+ replaceAllStrings(hContact2);
+ }
+ }
+ else {
+ char dbVar1[2000];
+ HANDLE hContact1 = (HANDLE)GetWindowLong(hwnd, GWLP_USERDATA), hContact2;
+ if (db_get_static(hContact1, MODNAME, "Name", dbVar1)) {
+ if (!(hContact2 =(HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0))) {
+ msg("contact did not get created","");
+ return 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"));
+ db_set_s(hContact2, MODNAME, "Name", dbVar1);
+ if (db_get_static(hContact1, MODNAME, "ProgramString",dbVar1))
+ db_set_s(hContact2, MODNAME, "ProgramString", dbVar1);
+
+ // copy the ProgramParamString
+ if (db_get_static(hContact1, MODNAME, "ProgramParamString",dbVar1))
+ db_set_s(hContact2, MODNAME, "ProgramParamString", dbVar1);
+
+ // copy the group
+ if (db_get_static(hContact1, "CList", "Group",dbVar1))
+ db_set_s(hContact2, "CList", "Group", dbVar1);
+
+ // copy the ToolTip
+ if (db_get_static(hContact1, MODNAME, "ToolTip",dbVar1))
+ db_set_s(hContact2, MODNAME, "ToolTip", dbVar1);
+
+ // timer
+ db_set_b(hContact2, MODNAME, "UseTimer", (BYTE)db_get_b(hContact1, MODNAME, "UseTimer", 0));
+ db_set_b(hContact2, MODNAME, "Minutes", (BYTE)db_get_b(hContact1, MODNAME, "Minutes", 0));
+ db_set_w(hContact2, MODNAME, "Timer", (WORD)db_get_w(hContact1, MODNAME, "Timer", 0));
+
+ //icon
+ db_set_w(hContact2, MODNAME, "Icon", (WORD)db_get_w(hContact1, MODNAME, "Icon", 40072));
+ replaceAllStrings(hContact2);
+ }
+ }
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+void ExportContact(HANDLE hContact)
+{
+ FILE* file;
+ char szFileName[MAX_PATH];
+ char DBVar[1024];
+ int tmp;
+
+ 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 = fopen(szFileName, "a");
+ if (file)
+ {
+ if (db_get_static(hContact, MODNAME, "Name", DBVar))
+ {
+ fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ProgramString", DBVar))
+ fprintf(file, "ProgramString=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar))
+ fprintf(file, "ProgramParamString=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ToolTip", DBVar))
+ fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
+ if (db_get_static(hContact, "CList", "Group", DBVar))
+ fprintf(file, "Group=%s\r\n", DBVar);
+ if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072))
+ fprintf(file, "Icon=%d\r\n", tmp);
+ if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0))
+ fprintf(file, "UseTimer=%d\r\n", tmp);
+ if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1))
+ fprintf(file, "Minutes=%d\r\n", tmp);
+ if (tmp = db_get_w(hContact, MODNAME, "Timer", 0))
+ fprintf(file, "Timer=%d\r\n", tmp);
+ fprintf(file, "[/Non-IM Contact]\r\n");
+ }
+ else ("Contact is invalid",modFullname);
+ fclose(file);
+ }
+ }
+}
+
+INT_PTR ImportContacts(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact;
+ 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))
+ return 1;
+
+ FILE *file = fopen(fn, "r");
+ if (!file)
+ return 1;
+
+ while (fgets(line,2000,file)) {
+ if (!strcmp(line, "\r\n\0"))
+ continue;
+ if (!strcmp(line,"[Non-IM Contact]\r\n"))
+ contactDone = 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;
+ }
+ 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;
+ 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;
+ while (line[i] != '\r' && line[i] != '\n' && line[i] != '\0') {
+ group[j] = line[i++];
+ group[++j] = '\0';
+ }
+ }
+ 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);
+ }
+ // the line that has the </tooltip>
+ strncat(tooltip,line, strlen(line) - strlen("</tooltip>\r\n"));
+ }
+ else if (!strncmp(line, "Icon=", strlen("Icon="))) {
+ i = (int)strlen("Icon=");
+ sscanf(&line[i], "%d", &icon);
+ }
+ else if (!strncmp(line, "UseTimer=", strlen("UseTimer="))) {
+ i = (int)strlen("UseTimer=");
+ sscanf(&line[i], "%d", &usetimer);
+ }
+ else if (!strncmp(line, "Timer=" ,strlen("Timer="))) {
+ i = (int)strlen("Timer=");
+ sscanf(&line[i], "%d", &timer);
+ }
+ else if (!strncmp(line, "Minutes=", strlen("Minutes="))) {
+ i = (int)strlen("Minutes=");
+ sscanf(&line[i], "%d", &minutes);
+ }
+ else if (contactDone && !strcmp(line,"[/Non-IM Contact]\r\n")) {
+ if (!name) continue;
+ char *msg = (char*)malloc(strlen(name) + strlen("Do you want to import this Non-IM Contact?\r\n\r\nName: \r\n") + 1);
+ wsprintfA(msg, "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);
+ strcat(msg, "Program: ");
+ strcat(msg,program);
+ strcat(msg,"\r\n");
+ }
+ if (programparam) {
+ 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");
+ }
+ if (tooltip) {
+ msg = (char*)realloc(msg, strlen(msg) + strlen(tooltip) +strlen("ToolTip: \r\n") +1);
+ strcat(msg, "ToolTip: ");
+ strcat(msg,tooltip);
+ strcat(msg,"\r\n");
+ }
+ if (group) {
+ msg = (char*)realloc(msg, strlen(msg) + strlen(group) +strlen("Group: \r\n") +1);
+ strcat(msg, "Group: ");
+ strcat(msg,group);
+ strcat(msg,"\r\n");
+ }
+ if (icon) {
+ char tmp[64];
+ if (icon == ID_STATUS_ONLINE)
+ wsprintfA(tmp, "Icon: Online\r\n");
+ else if (icon == ID_STATUS_AWAY)
+ wsprintfA(tmp, "Icon: Away\r\n");
+ else if (icon == ID_STATUS_NA)
+ wsprintfA(tmp, "Icon: NA\r\n");
+ else if (icon == ID_STATUS_DND)
+ wsprintfA(tmp, "Icon: DND\r\n");
+ else if (icon == ID_STATUS_OCCUPIED)
+ wsprintfA(tmp, "Icon: Occupied\r\n");
+ else if (icon == ID_STATUS_FREECHAT)
+ wsprintfA(tmp, "Icon: Free For Chat\r\n");
+ else if (icon == ID_STATUS_INVISIBLE)
+ wsprintfA(tmp, "Icon: Invisible\r\n");
+ else if (icon == ID_STATUS_ONTHEPHONE)
+ wsprintfA(tmp, "Icon: On The Phone\r\n");
+ else if (icon == ID_STATUS_OUTTOLUNCH)
+ wsprintfA(tmp, "Icon: Out To Lunch\r\n");
+ msg = (char*)realloc(msg, strlen(msg) + strlen(tmp) +1);
+ strcat(msg,tmp);
+ }
+ if (usetimer && timer) {
+ char tmp[64],tmp2[8];
+ if (minutes)
+ strcpy(tmp2,"Minutes");
+ else strcpy(tmp2,"Seconds");
+ wsprintfA(tmp, "UseTimer: Yes\r\nTimer: %d %s",timer, tmp2);
+ msg = (char*)realloc(msg, strlen(msg) + strlen(tmp) +1);
+ strcat(msg,tmp);
+ }
+
+ if (MessageBoxA(0,msg,modFullname,MB_YESNO) == IDYES) {
+ if (!(hContact =(HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0))) {
+ msg("contact did get created","");
+ continue;
+ }
+ CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
+ CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, IGNOREEVENT_USERONLINE);
+ db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
+ db_set_s(hContact, MODNAME, "Name", name);
+ db_set_s(hContact, MODNAME, "ProgramString", program);
+ // copy the ProgramParamString
+ db_set_s(hContact, MODNAME, "ProgramParamString", programparam);
+ // copy the group
+ db_set_s(hContact, "CList", "Group", group);
+ // copy the ToolTip
+ db_set_s(hContact, MODNAME, "ToolTip", tooltip);
+ // timer
+ db_set_b(hContact, MODNAME, "UseTimer", (BYTE)usetimer);
+ db_set_b(hContact, MODNAME, "Minutes", (BYTE)minutes);
+ db_set_w(hContact, MODNAME, "Timer", (WORD)timer);
+ //icon
+ db_set_w(hContact, MODNAME, "Icon", (WORD)icon);
+ replaceAllStrings(hContact);
+ }
+ free(msg);
+ contactDone = 0;
+ name[0] = '\0';
+ program[0] = '\0';
+ programparam[0] = '\0';
+ group[0] = '\0';
+ tooltip[0] = '\0';
+ line[0] = '\0';
+ icon = 40072;
+ usetimer = 0;
+ minutes = 1;
+ timer = 0;
+ }
+ }
+ fclose(file);
+
+ return 1;
+}
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp new file mode 100644 index 0000000000..cf3aa6a977 --- /dev/null +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -0,0 +1,368 @@ +#include "commonheaders.h"
+
+int CALLBACK PropSheetProc(HWND hwnd, UINT uMsg, LPARAM lParam);
+
+void DoPropertySheet(HANDLE hContact, HINSTANCE hInst)
+{
+ char title[256], nick[256];
+ PROPSHEETPAGEA psp[4];
+ PROPSHEETHEADERA psh;
+
+ /* contact info */
+ ZeroMemory(&psp[0], sizeof(PROPSHEETPAGE));
+ psp[0].dwSize = sizeof(PROPSHEETPAGE);
+ psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[0].hInstance = hInst;
+ psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
+ psp[0].pszIcon = NULL;
+ psp[0].pfnDlgProc = DlgProcContactInfo;
+ psp[0].pszTitle = "Contacts Display Info";
+ psp[0].lParam = (LPARAM)(HANDLE)hContact;
+ psp[0].pfnCallback = NULL;
+
+ /* other settings */
+ ZeroMemory(&psp[1], sizeof(PROPSHEETPAGE));
+ psp[1].dwSize = sizeof(PROPSHEETPAGE);
+ psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[1].hInstance = hInst;
+ psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
+ psp[1].pszIcon = NULL;
+ psp[1].pfnDlgProc = DlgProcOtherStuff;
+ psp[1].pszTitle = "Link and CList Settings";
+ psp[1].lParam = (LPARAM)(HANDLE)hContact;
+ psp[1].pfnCallback = NULL;
+
+ /* files */
+ ZeroMemory(&psp[3], sizeof(PROPSHEETPAGE));
+ psp[3].dwSize = sizeof(PROPSHEETPAGE);
+ psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[3].hInstance = hInst;
+ psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
+ psp[3].pszIcon = NULL;
+ psp[3].pfnDlgProc = DlgProcFiles;
+ psp[3].pszTitle = "Files";
+ psp[3].lParam = 0;
+ psp[3].pfnCallback = NULL;
+
+ /* copy contact */
+ ZeroMemory(&psp[2], sizeof(PROPSHEETPAGE));
+ psp[2].dwSize = sizeof(PROPSHEETPAGE);
+ psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
+ psp[2].hInstance = hInst;
+ psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
+ psp[2].pszIcon = NULL;
+ psp[2].pfnDlgProc = DlgProcCopy;
+ psp[2].pszTitle = "Copy Contact";
+ psp[2].lParam = (LPARAM)(HANDLE)hContact;
+ psp[2].pfnCallback = NULL;
+
+
+ /* propery sheet header.. dont touch !!!! */
+ ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
+ psh.dwSize = sizeof(PROPSHEETHEADER);
+ psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
+ psh.hwndParent = NULL;
+ psh.hInstance = hInst;
+ psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
+ db_get_static(hContact, MODNAME, "Nick", nick);
+ wsprintfA(title, "Edit Non-IM Contact \"%s\"", nick);
+ psh.pszCaption = title;
+ psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
+ psh.nStartPage = 0;
+ psh.ppsp = (LPCPROPSHEETPAGEA) &psp;
+ psh.pfnCallback = PropSheetProc;
+
+ // Now do it and return
+ PropertySheetA(&psh);
+}
+
+INT_PTR addContact(WPARAM wParam,LPARAM lParam)
+{
+ char tmp[256];
+ HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
+ CallService(MS_IGNORE_IGNORE, (WPARAM)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,(WPARAM)hContact,0);
+ replaceAllStrings(hContact);
+ return 0;
+}
+
+INT_PTR editContact(WPARAM wParam,LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE)wParam;
+ char tmp[256];
+ if (!hContact)
+ {
+ hContact =(HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT,(WPARAM)hContact,(LPARAM)MODNAME);
+ CallService(MS_IGNORE_IGNORE, (WPARAM)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,(WPARAM)hContact,0);
+ replaceAllStrings(hContact);
+ return 0;
+}
+
+int CALLBACK PropSheetProc(HWND hwnd, UINT uMsg, LPARAM lParam)
+{
+ if (uMsg == PSCB_PRECREATE)
+ {
+ // Remove the DS_CONTEXTHELP style from the
+ // dialog box template
+ if (((DLGTEMPLATEEX*)lParam)->signature == 0xFFFF)
+ {
+ ((DLGTEMPLATEEX*)lParam)->style
+ &= ~DS_CONTEXTHELP;
+ }
+ else {
+ ((LPDLGTEMPLATE)lParam)->style
+ &= ~DS_CONTEXTHELP;
+ }
+ return TRUE;
+ }
+
+ /* prob not the best way but it works... i hope */
+ switch (lParam) {
+ case PSBTN_OK:
+ break;
+ case PSBTN_CANCEL:
+ break;
+ case PSBTN_FINISH:
+ break;
+ case PSBTN_APPLYNOW:
+ break;
+ }
+ return 0;
+}
+
+INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ {
+ char tmp[5];
+ TranslateDialogDefault(hwnd);
+ CheckDlgButton(hwnd, IDC_IGNORE_GLOBALSTATUS, db_get_b(NULL, MODNAME, "IgnoreGlobalStatusChange", 0));
+ CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(NULL, MODNAME, "AwayAsStatus", 0));
+ if (db_get_w(NULL, MODNAME, "Timer", 1))
+ {
+ EnableWindow(GetDlgItem(hwnd,IDC_TIMER_INT),1);
+ SetDlgItemTextA(hwnd, IDC_TIMER_INT, _itoa(db_get_w(NULL, MODNAME, "Timer", 1),tmp,10));
+ EnableWindow(GetDlgItem(hwnd,IDC_TIMER_TEXT),1);
+ }
+ else
+ {
+ CheckDlgButton(hwnd, IDC_DISABLETIMER, 1);
+ 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)) {
+ case IDC_DISABLETIMER:
+ 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);
+ if (!GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT)))
+ SetDlgItemTextA(hwnd, IDC_TIMER_INT,"1");
+ }
+ break;
+
+
+ return TRUE;
+ }
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ char tmp[5];
+ db_set_b(NULL, MODNAME, "IgnoreGlobalStatusChange", (BYTE)IsDlgButtonChecked(hwnd, IDC_IGNORE_GLOBALSTATUS));
+ db_set_b(NULL, MODNAME, "AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE));
+ if (!IsDlgButtonChecked(hwnd, IDC_DISABLETIMER) && GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT))) {
+ GetDlgItemTextA(hwnd, IDC_TIMER_INT, tmp, 4);
+ db_set_w(NULL, MODNAME, "Timer",(WORD)atoi(tmp));
+ }
+ else db_set_w(NULL, MODNAME, "Timer",0);
+ return TRUE;
+ }
+ }
+ break;
+ }
+ 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 {
+ char var[64];
+ int idCtrl;
+} braceList[VARS] =
+{
+ {"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_PTR CALLBACK HelpWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ {
+ char string[10000];
+ TranslateDialogDefault(hwnd);
+
+ strcpy(string, Translate("String replacing variables....\r\nThe following are all the valid variables that can be used. Refer to the readme for a proper explanation.\r\n\r\n"));
+ strcat(string, Translate("file(X)\t\t<- specifies the file to read from\r\nMUST be followed by either start() or end() or wholeline()\r\n"));
+ strcat(string, Translate("filename(X)\t\t<- copyies the filename of file X.\r\n"));
+ strcat(string, Translate("start(...)\t\t<-specifies where to start copying from.\r\n"));
+ strcat(string, Translate("end(...)\t\t<-specifies where to stop copying.\r\n"));
+ strcat(string, Translate("wholeline(line(...))\t<-specifies a whole line to copy\r\n\r\n"));
+ strcat(string, Translate("start() and end() explained\r\n.........................\r\n"));
+ strcat(string, Translate("MUST start with line() followed by a number or a string inside \" marks, OR csv(seperatorX) variable\r\n"));
+ strcat(string, Translate("The number specifies which character in the line to start/end copying.\r\nThe string specifies a string in the line to start/end copying.\r\n"));
+ strcat(string, Translate("csv(seperatorX) explained...\r\nseperator is either \"tab\" or \"space\" or any SINGLE character.\r\nX is the Xth seperator to pass before copying, (or to stop before)\r\n\r\n"));
+ strcat(string, Translate("Lastly the line(...) variable...\r\n"));
+ strcat(string, Translate("Inside the brackets must be either a number (to specify the line number), or a string inside \" marks (to use the line with that string), or lastline(X).\r\nthe X in lastline is the Xth line above the last line. i.e lastline(1) will use the 2nd last line of the file.\r\n"));
+ strcat(string, Translate("If searching for a line with u may put a + or - X after the closing ) i.e line(\"some words\")+3 to go 3 lines after the line with \"some words\".\r\n\r\n"));
+ strcat(string, Translate("Some Expamples...\r\n\r\n"));
+ strcat(string, Translate("filename(0) <- will display the filename of the 0th file\r\nfile(0)wholeline(line(0))) <- will display the whole first line of the 0th file\r\nfile(0)wholeline(line(\"hello\")-1))) <- the wholeline above the first occurance of \"hello\" in the file\r\nfile(0)start(line(lastline(1))csv(tab2))end(line(lastline())csv(tab4))) <- starts at the 2nd last line of the file, from the 2nd tab variable, untill the 4th tab variable in the last line (in the 0th file)\r\nfile(0)start(line(\"hello\")+1\"zzzz\")end(line(6)17)) <- starts from the first occurance of zzzz in the line after the first occurance of hello, untill the 17th character in the 6th line (starting from line 0) of the 0th file.\r\n"));
+ SetDlgItemTextA(hwnd, IDC_HELPTEXT,string);
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDOK:
+ DestroyWindow(hwnd);
+ break;
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwnd);
+ return TRUE;
+
+ case WM_COMMAND:
+ switch(LOWORD(wParam)) {
+ case IDC_HELPMSG:
+ CreateDialog(hInst,MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
+ break;
+
+ case IDCANCEL:
+ DestroyWindow(hwnd);
+ break;
+
+ case IDC_STRING:
+ if (HIWORD(wParam) == EN_CHANGE) {
+ char tmp[MAX_STRING_LENGTH];
+ int i=0,j;
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING))) {
+ GetDlgItemTextA(hwnd, IDC_STRING, tmp, MAX_STRING_LENGTH);
+ 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);
+ if (j)
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j-1]].idCtrl),0);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ 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);
+ if (j > 1)
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j-2]].idCtrl),1);
+ braceOrder[j-1] = 0;
+ break;
+ }
+ }
+ }
+ }
+ else {
+ for (j=0; j<MAX_BRACES; j++) {
+ if (!braceOrder[j]) break;
+ EnableWindow(GetDlgItem(hwnd, braceList[braceOrder[j]].idCtrl),0);
+ }
+ }
+ }
+ break;
+
+ case IDOK:
+ char str2replace[MAX_STRING_LENGTH], replacedString[MAX_STRING_LENGTH];
+ int error;
+ if (GetWindowTextLength(GetDlgItem(hwnd, IDC_STRING))) {
+ GetDlgItemTextA(hwnd, IDC_STRING, str2replace, MAX_STRING_LENGTH);
+ switch (stringReplacer(str2replace, replacedString, NULL)) {
+ case ERROR_NO_LINE_AFTER_VAR_F:
+ wsprintfA(replacedString, "ERROR: no %s","%line or %wholeline or %lastline after %fn");
+ error = 1;
+ break;
+ case ERROR_LINE_NOT_READ:
+ wsprintfA(replacedString, "ERROR: file couldnt be opened ");
+ error = 1;
+ break;
+ case ERROR_NO_FILE:
+ wsprintfA(replacedString, "ERROR: no file specified in settings");
+ error = 1;
+ break;
+ default:
+ error = 0;
+ }
+ SetDlgItemTextA(hwnd, IDC_ANSWER, replacedString);
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+INT_PTR testStringReplacer(WPARAM wParam, LPARAM lParam)
+{
+ CreateDialog(hInst, MAKEINTRESOURCE(IDD_TEST_LINE), 0, TestWindowDlgProc);
+ return 0;
+}
+
+INT_PTR LoadFilesDlg(WPARAM wParam, LPARAM lParam)
+{
+ CreateDialog(hInst,MAKEINTRESOURCE(IDD_ADD_FILE),0,DlgProcFiles);
+ return 0;
+}
diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp new file mode 100644 index 0000000000..5fdc819604 --- /dev/null +++ b/plugins/Non-IM Contact/src/files.cpp @@ -0,0 +1,350 @@ +#include "commonheaders.h"
+
+INT_PTR exportContacts(WPARAM wParam,LPARAM lParam)
+{
+ char fn[MAX_PATH];
+ if (!Openfile(fn, 0))
+ return 0;
+
+ FILE* file;
+ if (MessageBoxA(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)
+ return 0;
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ const char* proto = GetContactProto(hContact);
+ if (proto && !strcmp(proto, MODNAME)) {
+ int tmp;
+ char DBVar[1024];
+ if (db_get_static(hContact, MODNAME, "Name", DBVar)) {
+ fprintf(file, "\r\n[Non-IM Contact]\r\nName=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ProgramString", DBVar))
+ fprintf(file, "ProgramString=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ProgramParamString", DBVar))
+ fprintf(file, "ProgramParamString=%s\r\n", DBVar);
+ if (db_get_static(hContact, MODNAME, "ToolTip", DBVar))
+ fprintf(file, "ToolTip=%s</tooltip>\r\n", DBVar);
+ if (db_get_static(hContact, "CList", "Group", DBVar))
+ fprintf(file, "Group=%s\r\n", DBVar);
+ if (tmp = db_get_w(hContact, MODNAME, "Icon", 40072))
+ fprintf(file, "Icon=%d\r\n", tmp);
+ if (tmp = db_get_b(hContact, MODNAME, "UseTimer", 0))
+ fprintf(file, "UseTimer=%d\r\n", tmp);
+ if (tmp = db_get_b(hContact, MODNAME, "Minutes", 1))
+ fprintf(file, "Minutes=%d\r\n", tmp);
+ if (tmp = db_get_w(hContact, MODNAME, "Timer", 0))
+ fprintf(file, "Timer=%d\r\n", tmp);
+ fprintf(file, "[/Non-IM Contact]\r\n");
+ }
+ }
+ }
+ fclose(file);
+ return 0;
+}
+
+int Openfile(char *outputFile, int saveOpen) //0=save, 1=open
+{
+ 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");
+
+ 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.lpstrTitle = title;
+ ofn.nMaxFile = MAX_PATH;
+
+ if (saveOpen)
+ r = GetOpenFileNameA(&ofn);
+ else
+ r = GetSaveFileNameA(&ofn);
+ if (!r)
+ return 0;
+ lstrcpyA(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++)
+ {
+ wsprintfA(fn, "fn%d", i);
+ if (db_get_static(NULL, MODNAME, fn, file)) {
+ index = SendMessageA(fileList, CB_ADDSTRING,0, (LPARAM)(char*)file);
+ SendMessage(fileList, CB_SETITEMDATA, index, (LPARAM)(int)i);
+ SendMessage(fileList, CB_SETCURSEL, index,0);
+ SetDlgItemTextA(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);
+ wsprintfA(fn, "fn%d", fileNumber);
+ if (!db_get_static(NULL, MODNAME, fn, szFileName)) {
+ msg(Translate("File couldn't be opened"),fn);
+ return;
+ }
+
+ if ( (!strncmp("http://", szFileName, strlen("http://"))) || (!strncmp("https://", szFileName, strlen("https://"))) )
+ wsprintfA(szFileName,"%s\\plugins\\fn%d.html",getMimDir(temp), fileNumber);
+
+ filen = fopen(szFileName,"r");
+ if (!filen) {
+ MessageBoxA(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';
+ wsprintfA( 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)*db_get_b(NULL, MODNAME, "WidthMultiplier", 5)))
+ SendMessage(GetDlgItem(hwnd, IDC_FILE_CONTENTS),LB_SETHORIZONTALEXTENT,(strlen(temp1)*db_get_b(NULL, MODNAME, "WidthMultiplier", 5)),0);
+ }
+ fclose(filen);
+
+ return ;
+}
+
+#define WM_RELOADWINDOW (WM_USER+11)
+
+INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg) {
+ case WM_RELOADWINDOW:
+ {
+ char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
+ reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
+ int i = SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_GETCURSEL, 0 ,0);
+ wsprintfA(fn , "fn%d", i);
+ SendMessage(GetDlgItem(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);
+ SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(db_get_w(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;
+ GetDlgItemTextA(hwnd,IDC_URL,text,sizeof(text));
+ strcpy(url, text);
+ if (!InternetDownloadFile(text))
+ {
+ for (i=0; ;i++)
+ {
+ wsprintfA(fn, "fn%d", i);
+ if (!db_get_static(NULL, MODNAME, fn, text))
+ break;
+ }
+ wsprintfA(szFileName,"%s\\plugins\\%s.html",getMimDir(temp), fn);
+ if (savehtml(szFileName))
+ {
+ wsprintfA(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);
+ }
+ db_set_w(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++)
+ {
+ wsprintfA(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 = 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);
+ SetDlgItemTextA(hwnd, IDC_FN, _itoa(i, fn, 10));
+ wsprintfA(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)
+ {
+ wsprintfA(fn, "fn%d", index);
+ db_unset(NULL, MODNAME, fn);
+ SendMessage(GetDlgItem(hwnd, IDC_FILE_LIST),CB_DELETESTRING, index ,0);
+ SendMessage(hwnd, WM_RELOADWINDOW, 0,0);
+ if (!index) {
+ SetDlgItemTextA(hwnd, IDC_FN,"");
+ SetDlgItemTextA(hwnd, IDC_FILE_CONTENTS,"");
+ }
+
+ }
+ else
+ {
+ wsprintfA(fn, "fn%d", i);
+ while (db_get_static(NULL, MODNAME, fn,tmp))
+ {
+ wsprintfA(fn1, "fn%d", i-1);
+ db_set_s(NULL, MODNAME, fn1 , tmp);
+ wsprintfA(fn, "fn%d", ++i);
+ }
+ wsprintfA(fn, "fn%d", --i);
+ db_unset(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];
+ SetDlgItemTextA(hwnd, IDC_FN, _itoa(index, fn, 10));
+ wsprintfA(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);
+ SetDlgItemTextA(hwnd, IDC_WWW_TIMER, _itoa(db_get_w(NULL, MODNAME, strcat(fn, "_timer"), 60), tmp, 10));
+ }
+ else
+ {
+ SetDlgItemTextA(hwnd,IDC_URL, "");
+ SetDlgItemTextA(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];;
+ wsprintfA(fn , "fn%d", i);
+ if (GetWindowTextLength(GetDlgItem(hwnd,IDC_WWW_TIMER))) {
+ char text[5];
+ GetDlgItemTextA(hwnd,IDC_WWW_TIMER,text,sizeof(text));
+ timer = atoi(text);
+ }
+ else timer = 60;
+
+ if (db_get_static(NULL, MODNAME, fn, string) )
+ if (!strncmp("http://", string, strlen("http://")) || !strncmp("https://", string, strlen("https://")))
+ db_set_w(NULL, MODNAME, strcat(fn, "_timer"), (WORD)timer);
+
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+char* getMimDir(char* file)
+{
+ GetModuleFileNameA(NULL, file, MAX_PATH);
+
+ char *p1 = strrchr(file,'\\');
+ if (p1)
+ *p1 = '\0';
+
+ if (file[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 new file mode 100644 index 0000000000..502d34e585 --- /dev/null +++ b/plugins/Non-IM Contact/src/http.cpp @@ -0,0 +1,103 @@ +/*
+Weather Protocol plugin for Miranda IM
+Copyright (C) 2002-2004 Calvin Che
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* This file contain the source related to downloading weather info
+ from the web using netlib
+*/
+
+#include "commonheaders.h"
+
+char *szInfo;
+char *szData;
+HANDLE hNetlibUser;
+
+// function to download webpage from the internet
+// 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)
+{
+ NETLIBHTTPREQUEST nlhr={0}, *nlhrReply;
+
+ // initialize the netlib request
+ 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);
+ CopyMemory(nlhr.headers,nlhr.headers,sizeof(NETLIBHTTPHEADER)*nlhr.headersCount);
+ nlhr.headers[nlhr.headersCount-1].szName="User-Agent";
+ nlhr.headers[nlhr.headersCount-1].szValue="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
+
+ // download the page
+ 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 (int)nlhrReply->resultCode;
+ // if the recieved code is 200 OK
+ else if (nlhrReply->resultCode == 200)
+ {
+ // allocate memory and save the retrieved data
+ szData = (char *)malloc(lstrlenA(nlhrReply->pData)+2);
+ lstrcpynA(szData, nlhrReply->pData, lstrlenA(nlhrReply->pData));
+ }
+ // if the recieved code is 302 Moved, Found, etc
+ 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++) {
+ if (!lstrcmpA(nlhrReply->headers[i].szName, "Location")) {
+ szData = (char *)malloc(512);
+ // add "Moved/Location:" in front of the new URL for identification
+ wsprintfA(szData, "Moved/Location: %s\n", nlhrReply->headers[i].szValue);
+ break;
+ }
+ }
+ // log the new url into netlib log
+ CallService(MS_NETLIB_LOG,(WPARAM)hNetlibUser,(LPARAM)szData);
+ }
+ }
+ // if the data does not downloaded successfully (ie. disconnected), then return 1 as error code
+ else return 1;
+
+ // make a copy of the retrieved data, then free the memory of the http reply
+ szInfo = szData;
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT,0,(LPARAM)nlhrReply);
+
+ // the recieved data is empty, data was not recieved, so return an error code of 1
+ if (!lstrcmpA(szInfo, "")) return 1;
+ return 0;
+}
+
+//============ NETLIB INITIALIZATION ============
+
+// initialize netlib support from weather protocol
+void NetlibInit() {
+ NETLIBUSER nlu={0};
+ nlu.cbSize=sizeof(nlu);
+ nlu.flags=NUF_OUTGOING|NUF_HTTPCONNS|NUF_NOHTTPSOPTION;
+ nlu.szSettingsModule= MODNAME;
+ nlu.szDescriptiveName= Translate("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 new file mode 100644 index 0000000000..9a96749ed5 --- /dev/null +++ b/plugins/Non-IM Contact/src/main.cpp @@ -0,0 +1,199 @@ +//=====================================================
+// Includes
+//=====================================================
+
+#include "commonheaders.h"
+
+#include "Version.h"
+
+HINSTANCE hInst;
+int hLangpack;
+
+PLUGININFOEX pluginInfoEx = {
+ sizeof(pluginInfoEx),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ //2e0d2ae3-e123-4607-8539-d4448d675ddb
+ { 0x2e0d2ae3, 0xe123, 0x4607, {0x85, 0x39, 0xd4, 0x44, 0x8d, 0x67, 0x5d, 0xdb} }
+};
+
+INT_PTR doubleClick(WPARAM wParam,LPARAM lParam)
+{
+ char program[MAX_PATH], params[MAX_PATH];
+ int shellEXEerror = 0;
+ char* proto = GetContactProto((HANDLE)wParam);
+ if (proto && !strcmp(proto, MODNAME)) {
+ if (GetKeyState(VK_CONTROL)&0x8000) // ctrl is pressed
+ editContact((WPARAM)(HANDLE)wParam, (LPARAM)NULL); // for later when i add a second double click setting
+ else if (db_get_static((HANDLE)wParam, MODNAME, "Program", program) && strcmp(program, ""))
+ {
+ if (!db_get_static((HANDLE)wParam, MODNAME, "ProgramParams", params) )
+ strcpy(params, "");
+ if (strstr(program, "http://") || strstr(program, "https://"))
+ CallService(MS_UTILS_OPENURL,1,(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,1,(LPARAM)program);
+ }
+ else editContact((WPARAM)(HANDLE)wParam, (LPARAM)NULL);
+ return 1;
+ }
+ return 0;
+}
+
+//=====================================================
+// Definitions
+//=====================================================
+int LCStatus = ID_STATUS_OFFLINE;
+//=====================================================
+
+//=====================================================
+// Name : MainInit
+// Parameters: wparam , lparam
+// Returns : int
+// Description : Called at very beginning of plugin
+//=====================================================
+int NimcOptInit(WPARAM wParam,LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
+ odp.pszGroup = LPGEN("Plugins");
+ odp.pszTitle = LPGEN("Non-IM Contacts");
+ odp.pfnDlgProc = DlgProcNimcOpts;
+ Options_AddPage(wParam, &odp);
+ return 0;
+}
+
+int MainInit(WPARAM wparam,LPARAM lparam)
+{
+ return 0;
+}
+
+//=====================================================
+// Name : __declspec(dllexport) PLUGININFO* MirandaPluginInfo
+// Parameters: (DWORD mirandaVersion)
+// Returns :
+// Description : Sets plugin info
+//=====================================================
+
+extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ return &pluginInfoEx;
+}
+
+//=====================================================
+// Name : WINAPI DllMain
+// Parameters: HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved
+// Returns : BOOL
+// Description :
+//=====================================================
+
+BOOL WINAPI DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved)
+{
+ hInst=hinst;
+ return TRUE;
+}
+
+int ModulesLoaded(WPARAM wParam,LPARAM lParam)
+{
+ NetlibInit();
+ return 0;
+}
+
+//=====================================================
+// Name : Load
+// Parameters: PLUGINLINK *link
+// Returns : int
+// Description : Called when plugin is loaded into Miranda
+//=====================================================
+
+extern "C" __declspec(dllexport) int Load()
+{
+ HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick);
+ HookEvent(ME_OPT_INITIALISE,NimcOptInit);
+ HookEvent(ME_CLIST_STATUSMODECHANGE, SetLCStatus);
+
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
+ pd.szName = MODNAME;
+ pd.type = PROTOTYPE_PROTOCOL;
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
+
+ //load services (the first 5 are the basic ones needed to make a new protocol)
+ CreateServiceFunction(MODNAME PS_GETCAPS, GetLCCaps);
+ CreateServiceFunction(MODNAME PS_GETNAME, GetLCName);
+ CreateServiceFunction(MODNAME PS_LOADICON, LoadLCIcon);
+ CreateServiceFunction(MODNAME PS_GETSTATUS, GetLCStatus);
+
+ CreateServiceFunction("AddLCcontact", addContact);
+ CreateServiceFunction("EditLCcontact", editContact);
+ CreateServiceFunction("LoadFilesDlg", LoadFilesDlg);
+ CreateServiceFunction("ExportLCcontacts", exportContacts);
+ CreateServiceFunction("ImportLCcontacts", ImportContacts);
+ CreateServiceFunction("TestStringReplaceLine", testStringReplacer);
+ CreateServiceFunction("NIM_Contact/DoubleClick", doubleClick);
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.position = 600090000;
+ mi.pszPopupName = LPGEN("&Non-IM Contact");
+ mi.popupPosition = 600090000;
+ mi.pszName = LPGEN("&Add Non-IM Contact");
+ mi.pszService = "AddLCcontact";
+ mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN));
+ Menu_AddMainMenuItem(&mi);
+
+ mi.position = 600090001;
+ mi.pszName = LPGEN("&View/Edit Files");
+ mi.pszService = "LoadFilesDlg";
+ mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_MAIN));
+ Menu_AddMainMenuItem(&mi);
+
+ if (db_get_b(NULL, MODNAME, "Beta",0)) {
+ mi.position = 600090000;
+ mi.pszName = LPGEN("&Export all Non-IM Contacts");
+ mi.pszService = "ExportLCcontacts";
+ Menu_AddMainMenuItem(&mi);
+
+ mi.pszName = LPGEN("&Import Non-IM Contacts");
+ mi.pszService = "ImportLCcontacts";
+ Menu_AddMainMenuItem(&mi);
+ }
+
+ mi.position = 600090000;
+ mi.pszPopupName = LPGEN("&Non-IM Contact");
+ mi.pszName = LPGEN("&String Maker");
+ mi.pszService = "TestStringReplaceLine";
+ Menu_AddMainMenuItem(&mi);
+
+ mi.position = -2000080000;
+ mi.pszContactOwner = MODNAME;
+ mi.pszName = LPGEN("E&dit Contact Settings");
+ mi.pszService = "EditLCcontact";
+ mi.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IDI_MAIN));
+ Menu_AddMainMenuItem(&mi);
+
+ hWindowList = (HWND)CallService(MS_UTILS_ALLOCWINDOWLIST,0,0);
+ HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
+
+ // known modules list
+ db_set_s(NULL, "KnownModules","Non-IM Contact", MODNAME);
+ return 0;
+}
+
+//=====================================================
+// Name : Unload
+// Parameters: void
+// Returns :
+// Description : Unloads plugin
+//=====================================================
+
+extern "C" __declspec(dllexport) int Unload(void)
+{
+ return 0;
+}
diff --git a/plugins/Non-IM Contact/src/namereplacing.cpp b/plugins/Non-IM Contact/src/namereplacing.cpp new file mode 100644 index 0000000000..8f3f07e82e --- /dev/null +++ b/plugins/Non-IM Contact/src/namereplacing.cpp @@ -0,0 +1,662 @@ +#include "commonheaders.h"
+
+int readFileIntoArray(int fileNumber, char *FileContents[])
+{
+ char dbSetting[20], temp[MAX_STRING_LENGTH];
+ wsprintfA(dbSetting, "fn%d", fileNumber);
+
+ DBVARIANT dbv;
+ char tszFileName[MAX_PATH];
+ if (db_get_ts(NULL,MODNAME, dbSetting, &dbv))
+ return 0;
+
+ if (!strncmp("http://", tszFileName, 7))
+ mir_snprintf(tszFileName, SIZEOF(tszFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), fileNumber);
+
+ FILE* file = fopen(tszFileName, "r");
+ if (file == NULL)
+ return 0;
+
+ // 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';
+
+ FileContents[i] = (char*)malloc(strlen(temp)+1);
+ if (FileContents[i] == NULL) return i;
+ strcpy(FileContents[i], temp);
+ }
+ fclose(file);
+ return i;
+}
+
+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];
+ strcpy(OpenDivider, Translate("(\""));
+ strcpy(CloseDivider, Translate("\")"));
+ /* get the word we r looking for */
+ if (!strncmp(string, OpenDivider, strlen(OpenDivider))) {
+ for (i=2; strncmp(&string[i], CloseDivider, strlen(CloseDivider)); i++) {
+ word[j] = string[i];
+ word[++j] = '\0';
+ }
+ }
+ i=0;
+ *lengthOfWord = 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))) {
+ if (!flag) return i + strlen(word); /* the next char after the word */
+ else return i; /* the char before the word */
+ }
+ i++;
+ }
+ return -1;
+}
+
+int findLine(char* FileContents[], const char* string, int linesInFile,int startLine, int *positionInOldString)
+{
+ char tmp[5];
+ int i = getNumber(&string[*positionInOldString]);
+
+ // check if blank
+ if (string[*positionInOldString] == ')')
+ return startLine;
+
+ // check if its a number
+ if (i != -1) {
+ *positionInOldString += strlen(_itoa(i,tmp,10)) - 1;
+ return i;
+ }
+
+ // lastline
+ if (!strncmp(&string[*positionInOldString], Translate("lastline("), strlen(Translate("lastline(")))) {
+ *positionInOldString += strlen(Translate("lastline("));
+ i = getNumber(&string[*positionInOldString]);
+ if ( i != -1) {
+ *positionInOldString += strlen(_itoa(i,tmp,10));
+ return linesInFile - (i+1);
+ }
+
+ *positionInOldString ++;
+ return (linesInFile - 1);
+ }
+
+ // string
+ if (string[*positionInOldString] == '\"') {
+ char string2Find[256];
+ int j=0;
+ // get the word to find
+ 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++) {
+ if (strstr(FileContents[j], string2Find)) {
+ i = j;
+ break;
+ }
+ i = -1;
+ }
+ *positionInOldString += strlen(string2Find) + strlen(Translate("\"\")"));
+ 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 += strlen(_itoa(j,tmp,10))-2;
+ return i+j;
+ }
+ }
+ else if (string[*positionInOldString] == '-') {
+ *positionInOldString+=1;
+ j = getNumber(&string[*positionInOldString]);
+ if (j != -1) {
+ *positionInOldString += strlen(_itoa(j,tmp,10))-2;
+ return i-j;
+ }
+ }
+ else {
+ *positionInOldString -= 2;
+ return i;
+ }
+ }
+ 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
+{
+ char tmp[5];
+ int i = getNumber(&string[*positionInOldString]);
+ // check if its a number
+ if (i != -1) {
+ *positionInOldString += strlen(_itoa(i,tmp,10)) - 1;
+ return i;
+ }
+
+ // string
+ if (string[*positionInOldString] == '\"') {
+ char string2Find[256];
+ unsigned int j=0;
+ // get the word to find
+ 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++)
+ if (!strncmp(&FileContents[startLine][j], string2Find, strlen(string2Find)))
+ break;
+
+ if (j==strlen(FileContents[startLine]))
+ return -1;
+
+ *positionInOldString += strlen(string2Find)+1;
+ return (startEnd) ? j : j+strlen(string2Find);
+ }
+
+ // csv(
+ if (!strncmp(&string[*positionInOldString], Translate("csv("), strlen(Translate("csv(")))) {
+ char seperator;
+ int j=0, k=startChar;
+ *positionInOldString += strlen(Translate("csv("));
+ if (!strncmp(&string[*positionInOldString], "tab", 3)) {
+ *positionInOldString += 3;
+ seperator = '\t';
+ }
+ else if (!strncmp(&string[*positionInOldString], "space",5)) {
+ *positionInOldString += 5;
+ seperator = ' ';
+ }
+ else {
+ seperator =string[*positionInOldString];
+ *positionInOldString += 1;
+ }
+ i = getNumber(&string[*positionInOldString]);
+ if ( i == -1) return -1;
+ *positionInOldString += strlen(_itoa(i,tmp,10));
+ while (j<i) {
+ if (FileContents[startLine][k] == '\0') break;
+ if (FileContents[startLine][k] == seperator)
+ j++;
+ k++;
+ }
+ return k;
+ }
+ return -1;
+}
+
+// do the compare("A","B","X","Y")
+void checkStringForcompare(char *str)
+{
+ char *A,*B, *X, *Y , *newStr = (char*)malloc(strlen(str)), *copyOfStr = _strdup(str);
+ unsigned int i, j=0, s=strlen(str);
+ newStr[0] = '\0';
+ if (!strstr(str,Translate("compare(\""))) return;
+ for (i=0; i<s; i++) {
+ if (!strncmp(&str[i], Translate("compare(\""), strlen(Translate("compare(\"")))) {
+ i += strlen(Translate("compare(\""));
+ A = strtok(©OfStr[i], "\",\"");
+ B = strtok(NULL, "\",\"");
+ X = strtok(NULL, "\",\"");
+ Y = strtok(NULL, ",\")");
+ j = Y - ©OfStr[i] + strlen(Y)+1;
+ if (A && B && X && Y)
+ {
+ if (!strcmp(A,B))
+ strcat(newStr, X);
+ else strcat(newStr, Y);
+ }
+ else strncat(newStr, &str[i], j);
+ i += j;
+ }
+ else strncat(newStr, &str[i], 1);
+ }
+ strcpy(str, newStr);
+ free(newStr);
+ free(copyOfStr);
+}
+
+// do save("A","B") A is DBVar name, B is value
+void checkStringForSave(HANDLE hContact, char* str)
+{
+ char *A,*B,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str);
+ unsigned int i, j=0, s=strlen(str);
+ newStr[0] = '\0';
+ if (!strstr(str,Translate("save(\""))) return;
+ for (i=0; i<s; i++) {
+ if (!strncmp(&str[i], Translate("save(\""), strlen(Translate("save(\"")))) {
+ i += strlen(Translate("save(\""));
+ A = strtok(©OfStr[i], "\",\"");
+ B = strtok(NULL, ",\")");
+ j = B - ©OfStr[i] + strlen(B)+1;
+ if (A && B)
+ db_set_s(hContact,MODNAME, A, B);
+
+ else strncat(newStr, &str[i], j);
+ i += j;
+ }
+ else strncat(newStr, &str[i], 1);
+ }
+ strcpy(str, newStr);
+ free(newStr);
+ free(copyOfStr);
+}
+
+// do load("A") A is DBVar name
+void checkStringForLoad(HANDLE hContact, char* str)
+{
+ char *A,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str);
+ unsigned int i, j=0, s=strlen(str);
+ newStr[0] = '\0';
+ if (!strstr(str,Translate("load(\""))) return;
+ for (i=0; i<s; i++) {
+ if (!strncmp(&str[i], Translate("load(\""), strlen(Translate("load(\"")))) {
+ i += strlen(Translate("load(\""));
+ A = strtok(©OfStr[i], "\")");
+ j = A - ©OfStr[i] + strlen(A)+1;
+ if (A) {
+ DBVARIANT dbv;
+ if ( !db_get_s(hContact, MODNAME, A, &dbv)) {
+ strcat(newStr, dbv.pszVal);
+ db_free(&dbv);
+ }
+ }
+ else strncat(newStr, &str[i], j);
+ i += j;
+ }
+ else strncat(newStr, &str[i], 1);
+ }
+ strcpy(str, newStr);
+ free(newStr);
+ free(copyOfStr);
+}
+
+// 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)
+{
+ char *A,*B,*C,*D,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str);
+ unsigned int i, j=0, s=strlen(str);
+ newStr[0] = '\0';
+ if (!strstr(str,Translate("saveN(\""))) return;
+ for (i=0; i<s; i++) {
+ if (!strncmp(&str[i], Translate("saveN(\""), strlen(Translate("saveN(\"")))) {
+ i += strlen(Translate("saveN(\""));
+ A = strtok(©OfStr[i], "\",\"");
+ B = strtok(NULL, ",\"");
+ C = strtok(NULL, ",\"");
+ D = strtok(NULL, ",\")");
+ j = D - ©OfStr[i] + strlen(D)+1;
+ if (A && B && C && D) {
+ switch (D[0]) {
+ case '0':
+ case 'b':
+ db_set_b(NULL, A, B, (BYTE)atoi(C));
+ break;
+ case '1':
+ case 'w':
+ db_set_w(NULL, A, B, (WORD)atoi(C));
+ break;
+ case '2':
+ case 'd':
+ db_set_dw(NULL, A, B, (DWORD)atoi(C));
+ break;
+ case '3':
+ case 's':
+ db_set_s(NULL, A, B, C);
+ break;
+ }
+ }
+ else strncat(newStr, &str[i], j);
+ i += j;
+ }
+ else strncat(newStr, &str[i], 1);
+ }
+ strcpy(str, newStr);
+ free(newStr);
+ free(copyOfStr);
+}
+
+// do loadN("A","B") A is module, B is setting
+void checkStringForLoadN(char* str)
+{
+ char *A,*B,*newStr = (char*)malloc(strlen(str)),*copyOfStr = _strdup(str), temp[32];
+ unsigned int i, j=0, s=strlen(str);
+ newStr[0] = '\0';
+ if (!strstr(str,Translate("loadN(\""))) return;
+ for (i=0; i<s; i++) {
+ if (!strncmp(&str[i], Translate("loadN(\""), strlen(Translate("loadN(\"")))) {
+ i += strlen(Translate("loadN(\""));
+ A = strtok(©OfStr[i], "\",\"");
+ B = strtok(NULL, ",\")");
+ j = B - ©OfStr[i] + strlen(B)+1;
+ if (A && B) {
+ DBVARIANT dbv;
+ if ( !db_get(NULL, A, B, &dbv)) {
+ switch (dbv.type) {
+ case DBVT_BYTE:
+ strcat(newStr,_itoa(dbv.bVal,temp,10));
+ break;
+ case DBVT_WORD:
+ strcat(newStr,_itoa(dbv.wVal,temp,10));
+ break;
+ case DBVT_DWORD:
+ strcat(newStr,_itoa(dbv.dVal,temp,10));
+ break;
+ case DBVT_ASCIIZ:
+ strcat(newStr, dbv.pszVal);
+ break;
+ }
+ db_free(&dbv);
+ }
+ }
+ else strncat(newStr, &str[i], j);
+ i += j;
+ }
+ else strncat(newStr, &str[i], 1);
+ }
+ strcpy(str, newStr);
+ free(newStr);
+ free(copyOfStr);
+}
+
+BOOL GetLastWriteTime(HANDLE hFile, LPSTR lpszString)
+{
+ FILETIME ftCreate, ftAccess, ftWrite;
+ SYSTEMTIME stUTC, stLocal;
+
+ // Retrieve the file times for the file.
+ if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite))
+ return FALSE;
+
+ // Convert the last-write time to local time.
+ FileTimeToSystemTime(&ftWrite, &stUTC);
+ SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal);
+
+ // Build a string showing the date and time.
+ wsprintfA(lpszString, "%02d/%02d/%d %02d:%02d",
+ stLocal.wDay, stLocal.wMonth, stLocal.wYear,
+ stLocal.wHour, stLocal.wMinute);
+
+ return TRUE;
+}
+
+// do lastchecked(file(X)) returns amount of chars to add to str pointer
+int lastChecked(char *newStr, const char *str)
+{
+ char *szPattern = Translate("lastchecked(file(");
+ size_t cbPattern = strlen(szPattern);
+
+ if (!strncmp(str, szPattern, cbPattern)) {
+ int file;
+ char tszFileName[MAX_PATH], temp[MAX_PATH], szSetting[20];
+ sscanf(&str[cbPattern], "%d", &file);
+ mir_snprintf(szSetting, SIZEOF(szSetting), "fn%d", file);
+
+ DBVARIANT dbv;
+ if (db_get_s(NULL, MODNAME, szSetting, &dbv))
+ return 0;
+
+ if (!strncmp("http://", dbv.pszVal, 7) || !strncmp("https://", dbv.pszVal, 8))
+ mir_snprintf(tszFileName, SIZEOF(tszFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), file);
+ else
+ strncpy(tszFileName, dbv.pszVal, SIZEOF(tszFileName));
+ HANDLE hFile = CreateFileA(tszFileName, 0, FILE_SHARE_READ, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (hFile == INVALID_HANDLE_VALUE)
+ return 0;
+
+ if (GetLastWriteTime(hFile, tszFileName)) {
+ CloseHandle(hFile);
+ strcat(newStr, tszFileName);
+ _snprintf(tszFileName, MAX_PATH, "%s%d))", szPattern, file);
+ return strlen(tszFileName);
+ }
+ CloseHandle(hFile);
+ }
+ return 0;
+}
+
+
+// do icon(x) 0=offline, 1=online, 10=lunch
+void checkIcon(HANDLE hContact, char* string)
+{
+ 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 stringReplacer(const char* oldString, char* newString, HANDLE hContact)
+{
+ char var_file[8];
+ int tempInt;
+ int startLine = 0, endLine = 0, startChar=0, endChar = 0, wholeLine=-1, linesInFile;
+ int positionInOldString = 0;
+ char *fileContents[MAXLINES] = {NULL}, tempString[MAX_STRING_LENGTH];
+
+ // setup the variable names
+ strcpy(newString, "");
+ strcpy(var_file, Translate("file("));
+
+ while ((positionInOldString < (int)strlen(oldString)) && (oldString[positionInOldString] != '\0'))
+ {
+ // load the file... must be first
+ if (!strncmp(&oldString[positionInOldString], var_file, strlen(var_file)))
+ {
+ positionInOldString += strlen(var_file);
+ // check if its a number
+ tempInt = getNumber(&oldString[positionInOldString]);
+ if (tempInt == -1)
+ {
+ // not a number so check vars..
+ // there are none yet
+ return ERROR_NO_FILE;
+ }
+ // read the file
+ linesInFile = readFileIntoArray(tempInt, fileContents);
+ if (linesInFile == 0) return ERROR_NO_FILE;
+ positionInOldString += strlen(_itoa(tempInt, tempString,10)) + 1; // +1 for the closing )
+
+ // wholeline()
+ if (!strncmp(&oldString[positionInOldString], Translate("wholeline(line("), strlen(Translate("wholeline(line("))))
+ {
+ positionInOldString += strlen(Translate("wholeline(line("));
+ tempInt = findLine(fileContents,oldString, linesInFile, startLine,&positionInOldString);
+ if (tempInt == -1|| !fileContents[tempInt])
+ return ERROR_NO_LINE_AFTER_VAR_F;
+ else wholeLine =tempInt;
+ positionInOldString += 3; // add 2 for the )) for wholeline(line())
+ }
+
+ if (!strncmp(&oldString[positionInOldString], Translate("start("), strlen(Translate("start("))))
+ {
+ positionInOldString += strlen(Translate("start(line("));
+ tempInt = findLine(fileContents,oldString, linesInFile, startLine,&positionInOldString);
+ if (tempInt == -1 || !fileContents[tempInt])
+ return ERROR_NO_LINE_AFTER_VAR_F;
+ else
+ {
+ positionInOldString+=2;
+ startLine = tempInt;
+ if (!endChar ) endChar = strlen(fileContents[startLine]);
+ tempInt = findChar(fileContents,oldString, linesInFile, startLine,&positionInOldString, startChar,0);
+ if (tempInt == -1)
+ return ERROR_NO_LINE_AFTER_VAR_F;
+ else startChar = tempInt;
+ }
+ positionInOldString += 2; // add 2 for the )) for start(line())
+ }
+ if (!strncmp(&oldString[positionInOldString], Translate("end("), strlen(Translate("end("))))
+ {
+ positionInOldString += strlen(Translate("end(line("));
+ tempInt = findLine(fileContents,oldString, linesInFile, startLine,&positionInOldString);
+ if (tempInt == -1 || !fileContents[tempInt])
+ return ERROR_NO_LINE_AFTER_VAR_F;
+ else
+ {
+ positionInOldString+=2;
+ endLine = tempInt;
+ tempInt = findChar(fileContents,oldString, linesInFile, startLine,&positionInOldString, startChar,1);
+ if (tempInt == -1)
+ return ERROR_NO_LINE_AFTER_VAR_F;
+ else endChar = tempInt;
+ }
+ positionInOldString += 2; // add 2 for the )) for end(line())
+ }
+ // check for both start() and end() otherwise, only copying 1 line
+ if (!strstr(oldString, Translate("start("))) startLine = endLine;
+ if (!strstr(oldString, Translate("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
+ {
+ // only copying from 1 line
+ if (startLine == endLine)
+ strncat(newString, &fileContents[startLine][startChar], endChar - startChar);
+ 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++)
+ {
+ strcat(newString, fileContents[i]);
+ }
+ // copy the last line untill endChar
+ strncat(newString, fileContents[endLine], endChar);
+ }
+ }
+ }
+ // filename()
+ else if (!strncmp(&oldString[positionInOldString], Translate("filename("), strlen(Translate("filename("))))
+ {
+ positionInOldString += strlen(Translate("filename("));
+ tempInt = getNumber(&oldString[positionInOldString]);
+ if (tempInt == -1)
+ {
+ return ERROR_NO_FILE;
+ }
+ else
+ {
+ wsprintfA(tempString, "fn%d", tempInt);
+ if (db_get_static(NULL, MODNAME,tempString, tempString))
+ strcat(newString, tempString);
+ else return ERROR_NO_FILE;
+ positionInOldString += strlen(_itoa(tempInt, tempString, 10))+1;
+ }
+ }
+ // lastchecked(file(X))
+ else if (!strncmp(&oldString[positionInOldString], Translate("lastchecked(file("), strlen(Translate("lastchecked(file("))))
+ {
+ positionInOldString += lastChecked(newString, &oldString[positionInOldString]);
+ }
+ else
+ {
+ strncat(newString, &oldString[positionInOldString], 1);
+ positionInOldString++;
+ }
+ }
+ // free the file strings
+ for (tempInt=0; (fileContents[tempInt] != NULL) && (tempInt<MAXLINES); tempInt++)
+ free(fileContents[tempInt]);
+
+
+
+ // check for load("A","B")
+ checkStringForLoad(hContact, newString);
+ // and loadN(...)
+ checkStringForLoadN(newString);
+ // check for compare("A","B","X","Y")
+ checkStringForcompare(newString);
+ // check for save("A","B")
+ checkStringForSave(hContact, newString);
+ // and saveN(...)
+ checkStringForSaveN(newString);
+ return 1;
+}
+
+void stripWhiteSpace(char* string)
+{
+ int i=0;
+ while (string[i] != '\0')
+ {
+ if ( (string[i] == '\t') || (string[i] == '\r') || (string[i] == '\n') )
+ string[i] = ' ';
+ i++;
+ }
+}
+void WriteSetting(HANDLE 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)) {
+ switch (stringReplacer(text, newString, hContact)) {
+ case ERROR_NO_LINE_AFTER_VAR_F:
+ wsprintfA(newString, Translate("%s - ERROR: no line specified or line not found (in %s)"),text, setting1);
+ error = 1;
+ break;
+ case ERROR_LINE_NOT_READ:
+ wsprintfA(newString, Translate("%s - ERROR: file couldnt be opened (in %s)"), text, setting1);
+ error = 1;
+ break;
+ case ERROR_NO_FILE:
+ wsprintfA(newString, Translate("%s - ERROR: no file specified in settings (in %s)"), text, setting1);
+ error = 1;
+ break;
+ default:
+ error = 0;
+ break;
+ }
+ // strip the tab and new lines from all except the tooltip
+ if (!error && strcmp(setting1, "ToolTip")) stripWhiteSpace(newString);
+ 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)
+ )
+ 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);
+}
+
+void replaceAllStrings(HANDLE hContact)
+{
+ char tmp1[256], tmp2[256], tmp3[256];
+ WriteSetting(hContact, MODNAME, "Name", MODNAME, "Nick");
+ WriteSetting(hContact, MODNAME, "ProgramString", MODNAME, "Program");
+ 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)) {
+ wsprintfA(tmp3, "%s %s", tmp1, tmp2);
+ db_set_s(hContact, "UserInfo", "FirstName", tmp3);
+ }
+ else if (db_get_static(hContact, MODNAME, "Program", tmp1))
+ {
+ db_set_s(hContact, "UserInfo", "FirstName", tmp1);
+ }
+ else db_set_s(hContact, "UserInfo", "FirstName", "");
+}
+
diff --git a/plugins/Non-IM Contact/src/resource.h b/plugins/Non-IM Contact/src/resource.h new file mode 100644 index 0000000000..928cde8564 --- /dev/null +++ b/plugins/Non-IM Contact/src/resource.h @@ -0,0 +1,77 @@ +//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by resource.rc
+//
+#define IDD_ADD_FILE 101
+#define IDI_MAIN 103
+#define IDD_CONTACT_INFO 104
+#define IDD_OTHER_STUFF 105
+#define IDI_ICON1 106
+#define IDD_CONTACT_COPYEXPORT 108
+#define IDD_OPTIONS 109
+#define IDD_TEST_LINE 110
+#define IDD_HELP 111
+#define IDC_FN 1000
+#define IDC_FILE_LIST 1001
+#define IDC_ADD_FILE 1002
+#define IDC_ADD_FILE2 1003
+#define IDC_DEL_FILE 1004
+#define IDC_FILE_CONTENTS 1005
+#define IDC_URL 1006
+#define IDC_ADD_URL 1007
+#define IDC_DISPLAY_NAME 1007
+#define IDC_TOOLTIP 1008
+#define IDC_GROUP 1008
+#define IDC_HELPMSG 1009
+#define IDC_LINK 1010
+#define IDC_PARAMS 1011
+#define IDC_OPEN_FILE 1012
+#define IDC_OPEN_FOLDER 1013
+#define CHK_USE_TIMER 1016
+#define IDC_TIMER 1017
+#define IDC_MINUTES 1018
+#define IDC_SECONDS 1019
+#define CHK_CTRL 1020
+#define IDC_WWW_TIMER 1022
+#define IDC_STRING_REPLACE 1025
+#define IDC_DOIT 1026
+#define IDC_EXPORT 1027
+#define IDC_ALWAYS_VISIBLE 1028
+#define IDC_VISIBLE_UNLESS_OFFLINE 1029
+#define IDC_IGNORE_GLOBALSTATUS 1030
+#define IDC_DISABLETIMER 1031
+#define IDC_TIMER_INT 1036
+#define IDC_AWAYISNOTONLINE 1037
+#define IDC_TIMER_TEXT 1039
+#define IDC_TIMER_MSG 1040
+#define IDC_STRING 1041
+#define IDC_ANSWER 1042
+#define IDC_LINE 1043
+#define IDC_START 1045
+#define IDC_END 1046
+#define IDC_WHOLELINE 1047
+#define IDC_CSV 1048
+#define IDC_FILE 1049
+#define IDC_FILENAME 1050
+#define IDC_TIMER_INTERVAL_MSG 1053
+#define IDC_HELPTEXT 1055
+#define CHK_ONLINE 40072
+#define CHK_AWAY 40073
+#define CHK_DND 40074
+#define CHK_NA 40075
+#define CHK_OCC 40076
+#define CHK_FFC 40077
+#define CHK_INVISIBLE 40078
+#define CHK_PHONE 40079
+#define CHK_LUNCH 40080
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 112
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1057
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/Non-IM Contact/src/services.cpp b/plugins/Non-IM Contact/src/services.cpp new file mode 100644 index 0000000000..1e547fb80c --- /dev/null +++ b/plugins/Non-IM Contact/src/services.cpp @@ -0,0 +1,127 @@ +#include "commonheaders.h"
+
+//=======================================================
+//db_get_static
+//=======================================================
+int db_get_static(HANDLE hContact, const char *szModule, const char *szSetting, char *value)
+{
+ DBVARIANT dbv;
+ if (!DBGetContactSetting(hContact, szModule, szSetting, &dbv))
+ {
+ strcpy(value, dbv.pszVal);
+ db_free(&dbv);
+ return 1;
+ }
+ else
+ {
+ db_free(&dbv);
+ return 0;
+ }
+
+ return 0;
+}
+
+//=======================================================
+//GetCaps
+//=======================================================
+
+INT_PTR GetLCCaps(WPARAM wParam,LPARAM lParam)
+{
+ if (wParam==PFLAGNUM_1)
+ return 0;
+ if (wParam==PFLAGNUM_2)
+ return PF2_ONLINE|PF2_LONGAWAY|PF2_SHORTAWAY|PF2_LIGHTDND|PF2_HEAVYDND|PF2_FREECHAT|PF2_INVISIBLE|PF2_OUTTOLUNCH|PF2_ONTHEPHONE; // add the possible statuses here.
+ if (wParam==PFLAGNUM_3)
+ return 0;
+ return 0;
+}
+
+//=======================================================
+//GetName
+//=======================================================
+INT_PTR GetLCName(WPARAM wParam,LPARAM lParam)
+{
+ lstrcpynA((char*)lParam, MODNAME, wParam);
+ return 0;
+}
+
+//=======================================================
+//BPLoadIcon
+//=======================================================
+INT_PTR LoadLCIcon(WPARAM wParam,LPARAM lParam)
+{
+ UINT id;
+
+ switch(wParam & 0xFFFF) {
+ case PLI_PROTOCOL: id=IDI_MAIN; break; // IDI_MAIN is the main icon for the protocol
+ default: return (int)(HICON)NULL;
+ }
+ return (int)LoadImage(hInst,MAKEINTRESOURCE(id),IMAGE_ICON,GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON),GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON),0);
+}
+
+//=======================================================
+//SetFStatus
+//=======================================================
+int SetLCStatus(WPARAM wParam,LPARAM lParam)
+{
+ int oldStatus;
+ HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
+ const char* szProto = (const char*)lParam;
+ if (szProto && strcmp(szProto, MODNAME)) return 0; // not nimc so ignore anyway...
+ else if (!szProto && db_get_b(NULL, MODNAME, "IgnoreGlobalStatusChange",0)) return 0; // global change and being ignored
+ else {
+ oldStatus = LCStatus;
+ LCStatus = wParam;
+ db_set_w(NULL, MODNAME, "Status", (WORD)wParam);
+ db_set_w(NULL, MODNAME, "timerCount",0);
+ if (LCStatus == ID_STATUS_OFFLINE || (LCStatus == ID_STATUS_AWAY && !db_get_b(NULL, MODNAME, "AwayAsStatus", 0)) || !db_get_w(NULL, MODNAME, "Timer",1)) killTimer();
+ else if (db_get_w(NULL, MODNAME, "Timer",1))
+ startTimer(TIMER);
+ while (hContact) {
+ char* proto = GetContactProto(hContact);
+ if (proto && !strcmp(proto, MODNAME)) {
+ if (LCStatus != ID_STATUS_OFFLINE) replaceAllStrings(hContact);
+ switch (LCStatus) {
+ case ID_STATUS_OFFLINE:
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) && !db_get_b(hContact, MODNAME, "VisibleUnlessOffline",1))
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ else
+ db_set_w(hContact,MODNAME, "Status", ID_STATUS_OFFLINE);
+ break;
+ case ID_STATUS_ONLINE:
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ break;
+ case ID_STATUS_AWAY:
+ if (db_get_b(NULL, MODNAME, "AwayAsStatus", 0) && (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || (db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE)==ID_STATUS_AWAY)) )
+ db_set_w(hContact,MODNAME, "Status",(WORD)(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ else if (!db_get_b(NULL, MODNAME, "AwayAsStatus", 0))
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ else
+ db_set_w(hContact,MODNAME, "Status", ID_STATUS_OFFLINE);
+ break;
+ default:
+ if (db_get_b(hContact, MODNAME, "AlwaysVisible",0) || LCStatus == db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE))
+ db_set_w(hContact,MODNAME, "Status",(WORD)db_get_w(hContact,MODNAME, "Icon",ID_STATUS_ONLINE));
+ break;
+ }
+ }
+ hContact = db_find_next(hContact);
+ }
+ ProtoBroadcastAck(MODNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)oldStatus,wParam);
+ }
+ return 0;
+}
+
+
+
+//=======================================================
+//GetStatus
+//=======================================================
+INT_PTR GetLCStatus(WPARAM wParam,LPARAM lParam)
+{
+ if ((LCStatus >= ID_STATUS_ONLINE) && (LCStatus <= ID_STATUS_OUTTOLUNCH))
+ return LCStatus;
+ else
+ return ID_STATUS_OFFLINE;
+}
+
diff --git a/plugins/Non-IM Contact/src/stdafx.cpp b/plugins/Non-IM Contact/src/stdafx.cpp new file mode 100644 index 0000000000..e7e41dae3c --- /dev/null +++ b/plugins/Non-IM Contact/src/stdafx.cpp @@ -0,0 +1,18 @@ +/*
+Copyright (C) 2012-13 Miranda NG Project (http://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "commonheaders.h"
\ No newline at end of file diff --git a/plugins/Non-IM Contact/src/timer.cpp b/plugins/Non-IM Contact/src/timer.cpp new file mode 100644 index 0000000000..42e2b47df1 --- /dev/null +++ b/plugins/Non-IM Contact/src/timer.cpp @@ -0,0 +1,84 @@ +#include "commonheaders.h"
+
+UINT_PTR timerId;
+
+//=====================================================
+// Name : timerProc
+// Parameters: none
+// Returns : void
+// Description : called when the timer interval occurs
+//=====================================================
+
+void timerFunc(LPVOID di)
+{
+ char text[512], fn[16], szFileName[MAX_PATH], temp[MAX_PATH];
+
+ int timerCount = db_get_w(NULL, MODNAME, "timerCount",1)+1;
+
+ if (LCStatus == ID_STATUS_OFFLINE) {
+ killTimer();
+ return;
+ }
+ db_set_w(NULL, MODNAME, "timerCount", (WORD)timerCount);
+
+ /* update the web pages*/
+ for (int i=0; ;i++) {
+ sprintf(fn, "fn%d", i);
+ if (!db_get_static(NULL, MODNAME, fn, text))
+ break;
+
+ if (!strncmp("http://", text, strlen("http://"))) {
+ strcat(fn, "_timer");
+ int timer = db_get_w(NULL, MODNAME, fn, 60);
+ if (timer && !(timerCount % timer)) {
+ if (!InternetDownloadFile(text)) {
+ mir_snprintf(szFileName, SIZEOF(szFileName), "%s\\plugins\\fn%d.html", getMimDir(temp), i);
+ savehtml(szFileName);
+ }
+ }
+ }
+ }
+
+ /* update all the contacts */
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (!strcmp(MODNAME, GetContactProto(hContact))) {
+ int timer = db_get_w(hContact, MODNAME, "Timer", 15);
+ if (timer && !(timerCount % timer))
+ if (db_get_static(hContact, MODNAME, "Name", text))
+ replaceAllStrings(hContact);
+ }
+ }
+}
+
+void CALLBACK timerProc(HWND, UINT, UINT_PTR, DWORD)
+{
+ // new thread for the timer...
+ forkthread(timerFunc, 0, 0);
+}
+
+//=====================================================
+// Name : startTimer
+// Parameters: int interval
+// Returns : int
+// Description : starts the timer
+//=====================================================
+
+int startTimer(int interval)
+{
+ timerId = SetTimer(NULL, 0, interval, timerProc);
+ return 0;
+}
+
+//=====================================================
+// Name : killTimer
+// Parameters: none
+// Returns : int
+// Description : stops the timer
+//=====================================================
+
+int killTimer()
+{
+ db_set_w(NULL, MODNAME, "timerCount",0);
+ KillTimer(NULL,timerId);
+ return 0;
+}
|