From cbd22101bcff041e598aba668412d0a4232b58e3 Mon Sep 17 00:00:00 2001 From: sje Date: Wed, 27 Jun 2007 17:05:05 +0000 Subject: git-svn-id: https://server.scottellis.com.au/svn/mim_plugs@217 4f64403b-2f21-0410-a795-97e2b3489a10 --- MySpace/Debug (Unicode)/BuildLog.htm | Bin 0 -> 9090 bytes MySpace/Debug (Unicode)/MySpace.dll | Bin 0 -> 499712 bytes .../MySpace.dll.intermediate.manifest | 3 + MySpace/Debug (Unicode)/MySpace.exp | Bin 0 -> 982 bytes MySpace/Debug (Unicode)/MySpace.ilk | Bin 0 -> 1076504 bytes MySpace/Debug (Unicode)/MySpace.lib | Bin 0 -> 2530 bytes MySpace/Debug (Unicode)/MySpace.obj | Bin 0 -> 7944 bytes MySpace/Debug (Unicode)/MySpace.pch | Bin 0 -> 4325376 bytes MySpace/Debug (Unicode)/MySpace.pdb | Bin 0 -> 2042880 bytes MySpace/Debug (Unicode)/NetMessage.obj | Bin 0 -> 86506 bytes MySpace/Debug (Unicode)/common.obj | Bin 0 -> 114375 bytes MySpace/Debug (Unicode)/menu.obj | Bin 0 -> 6905 bytes MySpace/Debug (Unicode)/mt.dep | 1 + MySpace/Debug (Unicode)/net.obj | Bin 0 -> 3969 bytes MySpace/Debug (Unicode)/options.obj | Bin 0 -> 10585 bytes MySpace/Debug (Unicode)/proto.obj | Bin 0 -> 12485 bytes MySpace/Debug (Unicode)/resource.res | Bin 0 -> 4400 bytes MySpace/Debug (Unicode)/server_con.obj | Bin 0 -> 21879 bytes MySpace/Debug (Unicode)/vc80.idb | Bin 0 -> 183296 bytes MySpace/Debug (Unicode)/vc80.pdb | Bin 0 -> 364544 bytes MySpace/MySpace.cpp | 87 ++++ MySpace/MySpace.rc | 127 +++++ MySpace/MySpace.sln | 26 + MySpace/MySpace.vcproj | 514 +++++++++++++++++++ MySpace/NetMessage.cpp | 214 ++++++++ MySpace/NetMessage.h | 58 +++ MySpace/Release (Unicode)/BuildLog.htm | Bin 0 -> 8708 bytes MySpace/Release (Unicode)/MySpace.dll | Bin 0 -> 94208 bytes .../MySpace.dll.intermediate.manifest | 3 + MySpace/Release (Unicode)/MySpace.exp | Bin 0 -> 984 bytes MySpace/Release (Unicode)/MySpace.lib | Bin 0 -> 2530 bytes MySpace/Release (Unicode)/MySpace.obj | Bin 0 -> 4741 bytes MySpace/Release (Unicode)/MySpace.pch | Bin 0 -> 4259840 bytes MySpace/Release (Unicode)/NetMessage.obj | Bin 0 -> 58104 bytes MySpace/Release (Unicode)/common.obj | Bin 0 -> 440 bytes MySpace/Release (Unicode)/menu.obj | Bin 0 -> 3834 bytes MySpace/Release (Unicode)/mt.dep | 1 + MySpace/Release (Unicode)/net.obj | Bin 0 -> 1686 bytes MySpace/Release (Unicode)/options.obj | Bin 0 -> 6964 bytes MySpace/Release (Unicode)/proto.obj | Bin 0 -> 8008 bytes MySpace/Release (Unicode)/resource.res | Bin 0 -> 4400 bytes MySpace/Release (Unicode)/server_con.obj | Bin 0 -> 14333 bytes MySpace/Release (Unicode)/vc80.idb | Bin 0 -> 183296 bytes MySpace/collection.h | 546 +++++++++++++++++++++ MySpace/common.cpp | 1 + MySpace/common.h | 67 +++ MySpace/icon1.ico | Bin 0 -> 766 bytes MySpace/menu.cpp | 75 +++ MySpace/menu.h | 7 + MySpace/menu.ico | Bin 0 -> 2550 bytes MySpace/net.cpp | 20 + MySpace/net.h | 10 + MySpace/options.cpp | 89 ++++ MySpace/options.h | 14 + MySpace/proto.cpp | 153 ++++++ MySpace/proto.h | 8 + MySpace/readme.txt | 47 ++ MySpace/resource.h | 21 + MySpace/resource.rc | 2 + MySpace/server_con.cpp | 124 +++++ MySpace/server_con.h | 9 + MySpace/version.h | 26 + MySpace/version.rc | 33 ++ 63 files changed, 2286 insertions(+) create mode 100644 MySpace/Debug (Unicode)/BuildLog.htm create mode 100644 MySpace/Debug (Unicode)/MySpace.dll create mode 100644 MySpace/Debug (Unicode)/MySpace.dll.intermediate.manifest create mode 100644 MySpace/Debug (Unicode)/MySpace.exp create mode 100644 MySpace/Debug (Unicode)/MySpace.ilk create mode 100644 MySpace/Debug (Unicode)/MySpace.lib create mode 100644 MySpace/Debug (Unicode)/MySpace.obj create mode 100644 MySpace/Debug (Unicode)/MySpace.pch create mode 100644 MySpace/Debug (Unicode)/MySpace.pdb create mode 100644 MySpace/Debug (Unicode)/NetMessage.obj create mode 100644 MySpace/Debug (Unicode)/common.obj create mode 100644 MySpace/Debug (Unicode)/menu.obj create mode 100644 MySpace/Debug (Unicode)/mt.dep create mode 100644 MySpace/Debug (Unicode)/net.obj create mode 100644 MySpace/Debug (Unicode)/options.obj create mode 100644 MySpace/Debug (Unicode)/proto.obj create mode 100644 MySpace/Debug (Unicode)/resource.res create mode 100644 MySpace/Debug (Unicode)/server_con.obj create mode 100644 MySpace/Debug (Unicode)/vc80.idb create mode 100644 MySpace/Debug (Unicode)/vc80.pdb create mode 100644 MySpace/MySpace.cpp create mode 100644 MySpace/MySpace.rc create mode 100644 MySpace/MySpace.sln create mode 100644 MySpace/MySpace.vcproj create mode 100644 MySpace/NetMessage.cpp create mode 100644 MySpace/NetMessage.h create mode 100644 MySpace/Release (Unicode)/BuildLog.htm create mode 100644 MySpace/Release (Unicode)/MySpace.dll create mode 100644 MySpace/Release (Unicode)/MySpace.dll.intermediate.manifest create mode 100644 MySpace/Release (Unicode)/MySpace.exp create mode 100644 MySpace/Release (Unicode)/MySpace.lib create mode 100644 MySpace/Release (Unicode)/MySpace.obj create mode 100644 MySpace/Release (Unicode)/MySpace.pch create mode 100644 MySpace/Release (Unicode)/NetMessage.obj create mode 100644 MySpace/Release (Unicode)/common.obj create mode 100644 MySpace/Release (Unicode)/menu.obj create mode 100644 MySpace/Release (Unicode)/mt.dep create mode 100644 MySpace/Release (Unicode)/net.obj create mode 100644 MySpace/Release (Unicode)/options.obj create mode 100644 MySpace/Release (Unicode)/proto.obj create mode 100644 MySpace/Release (Unicode)/resource.res create mode 100644 MySpace/Release (Unicode)/server_con.obj create mode 100644 MySpace/Release (Unicode)/vc80.idb create mode 100644 MySpace/collection.h create mode 100644 MySpace/common.cpp create mode 100644 MySpace/common.h create mode 100644 MySpace/icon1.ico create mode 100644 MySpace/menu.cpp create mode 100644 MySpace/menu.h create mode 100644 MySpace/menu.ico create mode 100644 MySpace/net.cpp create mode 100644 MySpace/net.h create mode 100644 MySpace/options.cpp create mode 100644 MySpace/options.h create mode 100644 MySpace/proto.cpp create mode 100644 MySpace/proto.h create mode 100644 MySpace/readme.txt create mode 100644 MySpace/resource.h create mode 100644 MySpace/resource.rc create mode 100644 MySpace/server_con.cpp create mode 100644 MySpace/server_con.h create mode 100644 MySpace/version.h create mode 100644 MySpace/version.rc diff --git a/MySpace/Debug (Unicode)/BuildLog.htm b/MySpace/Debug (Unicode)/BuildLog.htm new file mode 100644 index 0000000..8cc6727 Binary files /dev/null and b/MySpace/Debug (Unicode)/BuildLog.htm differ diff --git a/MySpace/Debug (Unicode)/MySpace.dll b/MySpace/Debug (Unicode)/MySpace.dll new file mode 100644 index 0000000..de8eb45 Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.dll differ diff --git a/MySpace/Debug (Unicode)/MySpace.dll.intermediate.manifest b/MySpace/Debug (Unicode)/MySpace.dll.intermediate.manifest new file mode 100644 index 0000000..cdaa604 --- /dev/null +++ b/MySpace/Debug (Unicode)/MySpace.dll.intermediate.manifest @@ -0,0 +1,3 @@ + + + diff --git a/MySpace/Debug (Unicode)/MySpace.exp b/MySpace/Debug (Unicode)/MySpace.exp new file mode 100644 index 0000000..b04813d Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.exp differ diff --git a/MySpace/Debug (Unicode)/MySpace.ilk b/MySpace/Debug (Unicode)/MySpace.ilk new file mode 100644 index 0000000..3f58702 Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.ilk differ diff --git a/MySpace/Debug (Unicode)/MySpace.lib b/MySpace/Debug (Unicode)/MySpace.lib new file mode 100644 index 0000000..665454a Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.lib differ diff --git a/MySpace/Debug (Unicode)/MySpace.obj b/MySpace/Debug (Unicode)/MySpace.obj new file mode 100644 index 0000000..856c965 Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.obj differ diff --git a/MySpace/Debug (Unicode)/MySpace.pch b/MySpace/Debug (Unicode)/MySpace.pch new file mode 100644 index 0000000..e446ff6 Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.pch differ diff --git a/MySpace/Debug (Unicode)/MySpace.pdb b/MySpace/Debug (Unicode)/MySpace.pdb new file mode 100644 index 0000000..2205025 Binary files /dev/null and b/MySpace/Debug (Unicode)/MySpace.pdb differ diff --git a/MySpace/Debug (Unicode)/NetMessage.obj b/MySpace/Debug (Unicode)/NetMessage.obj new file mode 100644 index 0000000..5ea42fc Binary files /dev/null and b/MySpace/Debug (Unicode)/NetMessage.obj differ diff --git a/MySpace/Debug (Unicode)/common.obj b/MySpace/Debug (Unicode)/common.obj new file mode 100644 index 0000000..fa18f52 Binary files /dev/null and b/MySpace/Debug (Unicode)/common.obj differ diff --git a/MySpace/Debug (Unicode)/menu.obj b/MySpace/Debug (Unicode)/menu.obj new file mode 100644 index 0000000..2d334d9 Binary files /dev/null and b/MySpace/Debug (Unicode)/menu.obj differ diff --git a/MySpace/Debug (Unicode)/mt.dep b/MySpace/Debug (Unicode)/mt.dep new file mode 100644 index 0000000..578b055 --- /dev/null +++ b/MySpace/Debug (Unicode)/mt.dep @@ -0,0 +1 @@ +Manifest resource last updated at 2:33:18.68 on Thu 28/06/2007 diff --git a/MySpace/Debug (Unicode)/net.obj b/MySpace/Debug (Unicode)/net.obj new file mode 100644 index 0000000..fc0bada Binary files /dev/null and b/MySpace/Debug (Unicode)/net.obj differ diff --git a/MySpace/Debug (Unicode)/options.obj b/MySpace/Debug (Unicode)/options.obj new file mode 100644 index 0000000..4c7a648 Binary files /dev/null and b/MySpace/Debug (Unicode)/options.obj differ diff --git a/MySpace/Debug (Unicode)/proto.obj b/MySpace/Debug (Unicode)/proto.obj new file mode 100644 index 0000000..13ee2e6 Binary files /dev/null and b/MySpace/Debug (Unicode)/proto.obj differ diff --git a/MySpace/Debug (Unicode)/resource.res b/MySpace/Debug (Unicode)/resource.res new file mode 100644 index 0000000..7d09e64 Binary files /dev/null and b/MySpace/Debug (Unicode)/resource.res differ diff --git a/MySpace/Debug (Unicode)/server_con.obj b/MySpace/Debug (Unicode)/server_con.obj new file mode 100644 index 0000000..0cda072 Binary files /dev/null and b/MySpace/Debug (Unicode)/server_con.obj differ diff --git a/MySpace/Debug (Unicode)/vc80.idb b/MySpace/Debug (Unicode)/vc80.idb new file mode 100644 index 0000000..fd75275 Binary files /dev/null and b/MySpace/Debug (Unicode)/vc80.idb differ diff --git a/MySpace/Debug (Unicode)/vc80.pdb b/MySpace/Debug (Unicode)/vc80.pdb new file mode 100644 index 0000000..2926416 Binary files /dev/null and b/MySpace/Debug (Unicode)/vc80.pdb differ diff --git a/MySpace/MySpace.cpp b/MySpace/MySpace.cpp new file mode 100644 index 0000000..39540df --- /dev/null +++ b/MySpace/MySpace.cpp @@ -0,0 +1,87 @@ +/* Replace "dll.h" with the name of your header */ +#include "common.h" +#include "version.h" +#include "resource.h" +#include "options.h" +#include "proto.h" +#include "net.h" +#include "menu.h" + +/////////////////////////////////////////////// +// Common Plugin Stuff +/////////////////////////////////////////////// +HINSTANCE hInst; +PLUGINLINK *pluginLink; +HANDLE mainThread; + +PLUGININFOEX pluginInfo={ + sizeof(PLUGININFOEX), + __PLUGIN_NAME, + PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM), + __DESC, + __AUTHOR, + __AUTHOREMAIL, + __COPYRIGHT, + __AUTHORWEB, + UNICODE_AWARE, + 0, + { 0xA0D1D7B2, 0x6B1, 0x437D, { 0x84, 0x91, 0xA7, 0x46, 0x58, 0xB9, 0x63, 0x70 } } +}; + + +extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) { + hInst=hinstDLL; + return TRUE; +} + +extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { + return &pluginInfo; +} + + +// uncomment this for pre 0.7 compatibility +extern "C" __declspec (dllexport) PLUGININFO* MirandaPluginInfo(DWORD mirandaVersion) { + pluginInfo.cbSize = sizeof(PLUGININFO); + return (PLUGININFO*)&pluginInfo; +} + +static const MUUID interfaces[] = {MIID_PROTOCOL, MIID_LAST}; +extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) +{ + return interfaces; +} + +int ModulesLoaded(WPARAM wParam, LPARAM lParam) { + InitNetlib(); + InitMenu(); + + return 0; +} + +HANDLE hModulesLoaded; +extern "C" __declspec (dllexport) int Load(PLUGINLINK *link) { + DuplicateHandle( GetCurrentProcess(), GetCurrentThread(), GetCurrentProcess(), &mainThread, THREAD_SET_CONTEXT, FALSE, 0 ); + + pluginLink=link; + + InitOptions(); + + ///////////// + ////// init protocol + RegisterProto(); + CreateProtoServices(); + + // hook modules loaded + hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded); + return 0; +} + +extern "C" __declspec (dllexport) int Unload(void) { + UnhookEvent(hModulesLoaded); + DeinitMenu(); + DeinitNetlib(); + DeinitProto(); + DeinitOptions(); + + return 0; +} diff --git a/MySpace/MySpace.rc b/MySpace/MySpace.rc new file mode 100644 index 0000000..8d49b6f --- /dev/null +++ b/MySpace/MySpace.rc @@ -0,0 +1,127 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Neutral (Default) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_OPT1 DIALOGEX 0, 0, 246, 179 +STYLE DS_SETFONT | WS_POPUP +FONT 8, "MS Sans Serif", 0, 0, 0x0 +BEGIN + GROUPBOX "MySpace",IDC_STATIC,26,17,201,89 + RTEXT "E-mail:",IDC_STATIC,40,39,54,8 + RTEXT "Password:",IDC_STATIC,35,72,59,8 + EDITTEXT IDC_ED_EMAIL,113,36,89,14,ES_AUTOHSCROLL + EDITTEXT IDC_ED_PW,113,68,89,14,ES_PASSWORD | ES_AUTOHSCROLL +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_MENU ICON "menu.ico" + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_OPT1, DIALOG + BEGIN + VERTGUIDE, 94 + VERTGUIDE, 113 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Neutral (Default) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// English (Australia) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON_PROTO ICON "icon1.ico" +#endif // English (Australia) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/MySpace/MySpace.sln b/MySpace/MySpace.sln new file mode 100644 index 0000000..688791b --- /dev/null +++ b/MySpace/MySpace.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MySpace", "MySpace.vcproj", "{EC43AA96-F631-49D9-944D-2B08571D1B66}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug (Unicode)|Win32 = Debug (Unicode)|Win32 + Debug|Win32 = Debug|Win32 + Release (Unicode)|Win32 = Release (Unicode)|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Debug (Unicode)|Win32.ActiveCfg = Debug (Unicode)|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Debug (Unicode)|Win32.Build.0 = Debug (Unicode)|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Debug|Win32.ActiveCfg = Debug|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Debug|Win32.Build.0 = Debug|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Release (Unicode)|Win32.ActiveCfg = Release (Unicode)|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Release (Unicode)|Win32.Build.0 = Release (Unicode)|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Release|Win32.ActiveCfg = Release|Win32 + {EC43AA96-F631-49D9-944D-2B08571D1B66}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/MySpace/MySpace.vcproj b/MySpace/MySpace.vcproj new file mode 100644 index 0000000..e0af73a --- /dev/null +++ b/MySpace/MySpace.vcproj @@ -0,0 +1,514 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MySpace/NetMessage.cpp b/MySpace/NetMessage.cpp new file mode 100644 index 0000000..92ce21e --- /dev/null +++ b/MySpace/NetMessage.cpp @@ -0,0 +1,214 @@ +#include "common.h" +#include "NetMessage.h" +#include + +NMString::NMString(): text(0) { +} + +NMString::NMString(const NMString &other) { + int len = strlen(other.text) + 1; + text = new char[len + 1]; + mir_snprintf(text, len, "%s", other.text); +} + +NMString::NMString(char *t) { + int len = strlen(t) + 1; + text = new char[len + 1]; + mir_snprintf(text, len, "%s", t); +} + +const bool NMString::operator<(const NMString &other) const { + return strcmp(text, other.text) < 0; +} + +const bool NMString::operator==(const NMString &other) const { + return strcmp(text, other.text) == 0; +} + +NMString &NMString::operator=(const NMString &other) { + if(text) delete[] text; + + int len = strlen(other.text) + 1; + text = new char[len + 1]; + mir_snprintf(text, len, "%s", other.text); + + return *this; +} + +NMString::~NMString() { + delete[] text; +} + +NetMessage::NetMessage(): Map() { +} + +NetMessage::~NetMessage() +{ +} + +//static +char *NetMessage::unescape_inplace(char *val) { + int read_pos = 0, write_pos = 0, len = strlen(val); + while(read_pos < len) { + if(val[read_pos] == '/' && read_pos + 1 < len) { + read_pos++; + if(val[read_pos] == '1') val[write_pos++] = '/'; + else if(val[read_pos] == '2') val[write_pos++] = '\\'; + else val[write_pos++] = '?'; + read_pos++; + } else { + val[write_pos++] = val[read_pos++]; + } + } + val[write_pos] = 0; + + return val; +} + +int NetMessage::parse(char *data, int size) { + int pos = 0; + bool finished = false; + char *key, *value; + int start, end = 0; + while(end < size && !finished) { + start = end + 1; + end = start; + while(end < size && data[end] != '\\') end++; + if(end < size) { + data[end] = 0; + key = &data[start]; + + start = end + 1; + end = start; + while(end < size && data[end] != '\\') end++; + if(end < size) { + data[end] = 0; + value = &data[start]; + } else + value = 0; + } else { + key = value = 0; + } + + if(key && strcmp(key, "final") == 0) + finished = true; + else if(key && value) + put(NMString(key), NMString(value)); + } + return pos; +} + +bool NetMessage::get_string(char *key, char *buff, int buffsize) { + NMString val; + if(get(NMString(key), val)) { + mir_snprintf(buff, buffsize, "%s", val.text); + unescape_inplace(buff); + return true; + } + return false; +} + +bool NetMessage::get_data(char *key, char *buff, int *size) { + NMString val; + if(get(NMString(key), val)) { + NETLIBBASE64 nbd = {0}; + nbd.pszEncoded = val.text; + nbd.cchEncoded = strlen(nbd.pszEncoded); + nbd.pbDecoded = (BYTE *)buff; + nbd.cbDecoded = *size; + + //*size = Netlib_GetBase64DecodedBufferSize(nbd.cchEncoded); + CallService(MS_NETLIB_BASE64DECODE, 0, (LPARAM)&nbd); + *size = nbd.cbDecoded; + + return true; + } + return false; +} + +int NetMessage::get_int(char *key) { + NMString val; + if(get(NMString(key), val)) { + return atoi(val.text); + } + return 0; +} + +ClientNetMessage::ClientNetMessage(): LinkedList< KeyValue >() { +} + +ClientNetMessage::~ClientNetMessage() { +} + +void ClientNetMessage::add_string(char *key, char *buff) { + char *temp = escape(buff); + KeyValue dat = KeyValue(NMString(key), NMString(temp)); + delete temp; + add(dat); +} + +void ClientNetMessage::add_data(char *key, char *data, int size) { + int len = Netlib_GetBase64EncodedBufferSize(size); + char *buff = new char[len]; + + NETLIBBASE64 nbd = {0}; + nbd.pszEncoded = buff; + nbd.cchEncoded = len; + nbd.pbDecoded = (BYTE *)data; + nbd.cbDecoded = size; + + //*size = Netlib_GetBase64DecodedBufferSize(nbd.cchEncoded); + CallService(MS_NETLIB_BASE64ENCODE, 0, (LPARAM)&nbd); + + KeyValue dat = KeyValue(NMString(key), NMString(buff)); + add(dat); +} + +void ClientNetMessage::add_int(char *key, int i) { + char buff[254]; + KeyValue dat(NMString(key), NMString(_itoa(i, buff, 10))); + add(dat); +} + +//static +char *ClientNetMessage::escape(char *val) { + int len = strlen(val); + char *buff = new char[len * 2 + 1]; + int read_pos = 0, write_pos = 0; + while(read_pos < len) { + if(val[read_pos] == '/') { + buff[write_pos++] = '/'; + buff[write_pos++] = '1'; + read_pos++; + } else if(val[read_pos] == '\\') { + buff[write_pos++] = '/'; + buff[write_pos++] = '2'; + read_pos++; + } else { + buff[write_pos++] = val[read_pos++]; + } + } + buff[write_pos] = 0; + return buff; +} + +int ClientNetMessage::make_packet(char *buff, int size) { + int pos = 0, key_len, val_len, len; + for(Iterator i = start(); i.has_val() && pos < size; i.next()) { + KeyValue v = i.val(); + + key_len = strlen(v.first.text); + val_len = strlen(v.second.text); + len = key_len + val_len + 2; + + if(size - pos - len > 0) + mir_snprintf(buff + pos, size - pos, "\\%s\\%s", v.first.text, v.second.text); + pos += len; + } + + if(size - pos > 7) { + mir_snprintf(buff + pos, size - pos, "\\final\\"); + pos += 7; + } + return pos; +} diff --git a/MySpace/NetMessage.h b/MySpace/NetMessage.h new file mode 100644 index 0000000..8261302 --- /dev/null +++ b/MySpace/NetMessage.h @@ -0,0 +1,58 @@ +#ifndef _NET_MESSAGE_INC +#define _NET_MESSAGE_INC + +#include "collection.h" + +class NMString { +public: + NMString(); + NMString(const NMString &other); + NMString(char *t); + virtual ~NMString(); + + const bool operator<(const NMString &other) const; + const bool operator==(const NMString &other) const; + NMString &operator=(const NMString &other); + + char *text; +}; + +class NetMessage: public Map { +public: + NetMessage(); + virtual ~NetMessage(); + + int parse(char *data, int size); + + bool get_string(char *key, char *buff, int buffsize); + bool get_data(char *key, char *buff, int *size); + int get_int(char *key); + + static char *unescape_inplace(char *val); +}; + +class KeyValue: public Pair { +public: + KeyValue(const NMString &k, const NMString &v): Pair(k, v) {} + KeyValue &operator=(const KeyValue &other) { + first = other.first; + second = other.second; + return *this; + } +}; + +class ClientNetMessage: public LinkedList< KeyValue > { +public: + ClientNetMessage(); + virtual ~ClientNetMessage(); + + int ClientNetMessage::make_packet(char *buff, int size); + + void add_string(char *key, char *buff); + void add_data(char *key, char *buff, int size); + void add_int(char *key, int i); + + static char *escape(char *val); +}; + +#endif diff --git a/MySpace/Release (Unicode)/BuildLog.htm b/MySpace/Release (Unicode)/BuildLog.htm new file mode 100644 index 0000000..79110e3 Binary files /dev/null and b/MySpace/Release (Unicode)/BuildLog.htm differ diff --git a/MySpace/Release (Unicode)/MySpace.dll b/MySpace/Release (Unicode)/MySpace.dll new file mode 100644 index 0000000..633c8b0 Binary files /dev/null and b/MySpace/Release (Unicode)/MySpace.dll differ diff --git a/MySpace/Release (Unicode)/MySpace.dll.intermediate.manifest b/MySpace/Release (Unicode)/MySpace.dll.intermediate.manifest new file mode 100644 index 0000000..cdaa604 --- /dev/null +++ b/MySpace/Release (Unicode)/MySpace.dll.intermediate.manifest @@ -0,0 +1,3 @@ + + + diff --git a/MySpace/Release (Unicode)/MySpace.exp b/MySpace/Release (Unicode)/MySpace.exp new file mode 100644 index 0000000..4336728 Binary files /dev/null and b/MySpace/Release (Unicode)/MySpace.exp differ diff --git a/MySpace/Release (Unicode)/MySpace.lib b/MySpace/Release (Unicode)/MySpace.lib new file mode 100644 index 0000000..5437b22 Binary files /dev/null and b/MySpace/Release (Unicode)/MySpace.lib differ diff --git a/MySpace/Release (Unicode)/MySpace.obj b/MySpace/Release (Unicode)/MySpace.obj new file mode 100644 index 0000000..7922084 Binary files /dev/null and b/MySpace/Release (Unicode)/MySpace.obj differ diff --git a/MySpace/Release (Unicode)/MySpace.pch b/MySpace/Release (Unicode)/MySpace.pch new file mode 100644 index 0000000..f8c2c06 Binary files /dev/null and b/MySpace/Release (Unicode)/MySpace.pch differ diff --git a/MySpace/Release (Unicode)/NetMessage.obj b/MySpace/Release (Unicode)/NetMessage.obj new file mode 100644 index 0000000..de8bd1d Binary files /dev/null and b/MySpace/Release (Unicode)/NetMessage.obj differ diff --git a/MySpace/Release (Unicode)/common.obj b/MySpace/Release (Unicode)/common.obj new file mode 100644 index 0000000..91d691f Binary files /dev/null and b/MySpace/Release (Unicode)/common.obj differ diff --git a/MySpace/Release (Unicode)/menu.obj b/MySpace/Release (Unicode)/menu.obj new file mode 100644 index 0000000..b67d9f0 Binary files /dev/null and b/MySpace/Release (Unicode)/menu.obj differ diff --git a/MySpace/Release (Unicode)/mt.dep b/MySpace/Release (Unicode)/mt.dep new file mode 100644 index 0000000..695ee7c --- /dev/null +++ b/MySpace/Release (Unicode)/mt.dep @@ -0,0 +1 @@ +Manifest resource last updated at 2:33:18.06 on Thu 28/06/2007 diff --git a/MySpace/Release (Unicode)/net.obj b/MySpace/Release (Unicode)/net.obj new file mode 100644 index 0000000..ea5cbf0 Binary files /dev/null and b/MySpace/Release (Unicode)/net.obj differ diff --git a/MySpace/Release (Unicode)/options.obj b/MySpace/Release (Unicode)/options.obj new file mode 100644 index 0000000..2dd6522 Binary files /dev/null and b/MySpace/Release (Unicode)/options.obj differ diff --git a/MySpace/Release (Unicode)/proto.obj b/MySpace/Release (Unicode)/proto.obj new file mode 100644 index 0000000..33a3a48 Binary files /dev/null and b/MySpace/Release (Unicode)/proto.obj differ diff --git a/MySpace/Release (Unicode)/resource.res b/MySpace/Release (Unicode)/resource.res new file mode 100644 index 0000000..7d09e64 Binary files /dev/null and b/MySpace/Release (Unicode)/resource.res differ diff --git a/MySpace/Release (Unicode)/server_con.obj b/MySpace/Release (Unicode)/server_con.obj new file mode 100644 index 0000000..a0c7129 Binary files /dev/null and b/MySpace/Release (Unicode)/server_con.obj differ diff --git a/MySpace/Release (Unicode)/vc80.idb b/MySpace/Release (Unicode)/vc80.idb new file mode 100644 index 0000000..3fa746c Binary files /dev/null and b/MySpace/Release (Unicode)/vc80.idb differ diff --git a/MySpace/collection.h b/MySpace/collection.h new file mode 100644 index 0000000..e02cedf --- /dev/null +++ b/MySpace/collection.h @@ -0,0 +1,546 @@ +template class Collection { +protected: + unsigned long count; +public: + Collection(): count(0) {} + + virtual void clear() = 0; + virtual void add(T &val) = 0; + virtual const bool remove(T &val) = 0; + + const unsigned long size() const {return count;} +}; + +template class Node { +public: + T val; + + Node(T &v): val(v) {} + virtual ~Node() {} +}; + +template class ListNode: public Node { +public: + ListNode *next, *prev; + + ListNode(T &v): Node(v), next(0), prev(0) {} + virtual ~ListNode() { + if(next) next->prev = prev; + if(prev) prev->next = next; + } +}; + +template class LinkedList: public Collection { +protected: + ListNode *head, *tail; + +public: + class Iterator { + friend class LinkedList; + protected: + ListNode *n; + Iterator(ListNode *start): n(start) {} + public: + Iterator(const Iterator &other): n(other.n) {} + + virtual T &val() {return n->val;} + virtual void next() {if(n) n = n->next;} + virtual void prev() {if(n) n = n->prev;} + virtual const bool has_val() {return (n ? true : false); } + }; + + LinkedList(): Collection(), head(0), tail(0) {}; + LinkedList(const LinkedList &other): Collection(), head(0), tail(0) { + for(Iterator i = other.start(); i.has_val(); i.next()) + add(i.val()); + } + virtual ~LinkedList() {clear();} + + LinkedList &operator=(const LinkedList &other) { + clear(); + for(Iterator i = other.start(); i.has_val(); i.next()) + add(i.val()); + return *this; + } + + virtual void clear() { + ListNode *n; + while(head) { + n = head; + head = head->next; + delete n; + } + tail = 0; + Collection::count = 0; + } + + virtual Iterator start() const {return Iterator(head);} + + virtual void add_front(T &val) { + ListNode *n = new ListNode(val); + n->next = head; + if(head) head->prev = n; + head = n; + if(!tail) tail = n; + Collection::count++; + } + + virtual void add(T &val) { + ListNode *n = new ListNode(val); + n->prev = tail; + if(tail) tail->next = n; + tail = n; + if(!head) head = n; + Collection::count++; + } + + virtual const bool remove(T &val) { + ListNode *n = head; + while(n) { + if(n->val == val) { + if(n == head) head = head->next; + if(n == tail) tail = tail->prev; + + delete n; + Collection::count--; + return true; + } else + n = n->next; + } + + return false; + } + + // queue/stack functions + // stack - use push/pop + // queue - use push_back/pop + virtual void push(T &val) { + add_front(val); + } + + virtual void push(T val) { + add_front(val); + } + + virtual void push_back(T &val) { + add(val); + } + + virtual const bool pop(T &val) { + if(!head) return false; + + ListNode *n = head; + if(head) { + head = head->next; + if(n == tail) tail = 0; + val = n->val; + delete n; + Collection::count--; + return true; + } else + return false; + } +}; + +template class DynamicArray: public Collection { +protected: + T *ar; + + unsigned long initial, limit, increment; + +public: + class Iterator { + friend class DynamicArray; + protected: + T *ar; + unsigned long count; + unsigned long pos; + Iterator(T *a, const int c, unsigned long p): ar(a), count(c), pos(p) {} + public: + Iterator(const Iterator &other): ar(other.ar), count(other.count), pos(other.pos) {} + + virtual T &val() {return ar[pos];} + virtual void next() {pos++;} + virtual void prev() {pos--;} + virtual const bool has_val() {return pos < count; } + }; + + DynamicArray(unsigned long init = 0, unsigned long inc = 1): Collection(), ar(0), initial(init), limit(init), increment(inc) { + if(limit) ar = (T *)malloc(limit * sizeof(T)); + } + virtual ~DynamicArray() {if(ar) free(ar);} + + virtual void clear() { + Collection::count = 0; + limit = initial; + if(limit) ar = (T *)realloc(ar, limit * sizeof(T)); + else free(ar); + } + + virtual Iterator start() {return Iterator(ar, Collection::count, 0);} + + virtual void add(T &val) { + if(Collection::count == limit) { + limit += increment; + ar = (T *)realloc(ar, limit * sizeof(T)); + ar[Collection::count++] = val; + } else + ar[Collection::count++] = val; + } + + virtual const bool remove(T &val) { + for(unsigned long i = 0; i < Collection::count; i++) { + if(ar[i] == val) { + memmove(ar + i, ar + i + 1, (Collection::count - i) * sizeof(T)); + Collection::count--; + return true; + } + } + return false; + } + + virtual const bool remove(const unsigned long index) { + if(index >= Collection::count) return false; + + memmove(ar + index, ar + index + 1, (Collection::count - index) * sizeof(T)); + Collection::count--; + return true; + } + + virtual const bool insert(T &val, const unsigned long index) { + if(index > Collection::count) return false; + + if(Collection::count == limit) { + limit += increment; + ar = (T *)realloc(ar, limit * sizeof(T)); + } + + if(index < Collection::count) + memmove(ar + index + 1, ar + index, (Collection::count - index) * sizeof(T)); + + ar[index] = val; + Collection::count++; + return true; + } + + virtual T &operator[](const int index) { + return ar[index]; + } + + const bool index_of(const T &val, unsigned long &index) { + for(int i = 0; i < Collection::count; i++) { + if(ar[index] == val) { + index = i; + return true; + } + } + return false; + } + + // stack functions + virtual const bool pop(T &val) { + if(Collection::count) { + val = ar[Collection::count -1]; + remove(Collection::count -1); + return true; + } + return false; + } + + virtual void push(T &val) { + add(val); + } +}; + +template class SortedDynamicArray: public DynamicArray { +public: + SortedDynamicArray(unsigned long init = 0, unsigned long inc = 1): DynamicArray(init, inc) {} + virtual ~SortedDynamicArray() {} + + const bool get_index(T &val, unsigned long &index) { + unsigned long low = 0; + unsigned long high = Collection::count-1; + + while( high < Collection::count && low <= high ) + { + unsigned long i = ( low+high )/2; + if ( DynamicArray::ar[i] == val ) + { index = i; + return true; + } else + if (DynamicArray::ar[i] < val) + low = i+1; + else + high = i-1; + } + + index = low; + return false; + } + + virtual void add(T &val) { + unsigned long index; + get_index(val, index); + insert(val, index); + } +}; + +template class TreeNode: public Node { +public: + TreeNode *parent, *left, *right; + + TreeNode(T &v, TreeNode *par): Node(v), parent(par), left(0), right(0) {} + virtual ~TreeNode() { + if(parent) { + if(parent->left == this) parent->left = 0; + else parent->right = 0; + } + } +}; + +template class BinaryTree: public Collection { +protected: + + TreeNode *root; + + TreeNode *delete_node(TreeNode *n) { + if(n->left && n->right) { + //if(rand() & 1) { // ? + TreeNode *minmax = n->left; + while(minmax->right) minmax = minmax->right; + //} else { + // Node *minmax = current->right; + // while(minmax->left) minmax = minmax->left; + //} + n->val = minmax->val; + delete_node(minmax); + Collection::count--; + return n; + } else if(n->right) { + if(n->parent) { + if(n->parent->left = n) n->parent->left = n->right; + else n->parent->right = n->right; + } else + root = n->right; + n->right->parent = n->parent; + } else if(n->left) { + if(n->parent) { + if(n->parent->left = n) n->parent->left = n->left; + else n->parent->right = n->left; + } else + root = n->left; + n->left->parent = n->parent; + } else { + if(n == root) root = 0; + } + delete n; + Collection::count--; + return 0; + } + + void insert_node(TreeNode *n) { + TreeNode *current = root, *parent = 0; + while(current) { + parent = current; + if(n->val < current->val) + current = current->left; + else + current = current->right; + } + + if(parent) { + if(n->val < parent->val) { + parent->left = n; + n->parent = parent; + } else { + parent->right = n; + n->parent = parent; + } + } else + root = n; + + } + +public: + class Iterator { + friend class BinaryTree; + protected: + + class EvalNode { + public: + bool evaluate; + TreeNode *node; + + EvalNode(): evaluate(false), node(0) {} + EvalNode(const bool eval, TreeNode *n): evaluate(eval), node(n) {} + const bool operator==(const EvalNode &other) const {return node == other.node;} + EvalNode &operator=(const EvalNode &other) {evaluate = other.evaluate; node = other.node; return *this;} + + }; + + TreeNode *n; + LinkedList stack; + + + Iterator(TreeNode *start): n(0) { + if(start) { + stack.push(EvalNode(true, start)); + next(); + } + } + + public: + Iterator(const Iterator &other):n(other.n), stack(other.stack) {} + virtual ~Iterator() {} + + virtual T &val() {return n->val;} + virtual void next() { + EvalNode en; + bool popped = false; + while((popped = stack.pop(en)) && en.evaluate) { + if(en.node->right) stack.push(EvalNode(true, en.node->right)); + stack.push(EvalNode(false, en.node)); + if(en.node->left) stack.push(EvalNode(true, en.node->left)); + } + + n = (popped ? en.node : 0); + } + virtual const bool has_val() {return (n ? true : false);} + }; + + BinaryTree(): Collection(), root(0) {}; + BinaryTree(BinaryTree &other): Collection(), root(0) { + for(Iterator i = other.start(); i.has_val(); i.next()) + add(i.val()); + } + virtual ~BinaryTree() {clear();} + + BinaryTree &operator=(BinaryTree &other) { + clear(); + for(Iterator i = other.start(); i.has_val(); i.next()) + add(i.val()); + return *this; + } + + virtual void clear() { + TreeNode *current = root, *parent = 0; + while(current) { + if(current->left) current = current->left; + else if(current->right) current = current->right; + else { + parent = current->parent; + delete current; + current = parent; + } + } + + root = 0; + Collection::count = 0; + } + + void add(T &val) { + TreeNode *n = new TreeNode(val, 0); + insert_node(n); + Collection::count++; + } + + const bool remove(T &val) { + TreeNode *current = root; + while(current) { + if(current->val == val) + break; + else if(val < current->val) + current = current->left; + else + current = current->right; + } + + if(current) { + delete_node(current); + return true; + } + + return false; + } + + Iterator start() {return Iterator(root);} +}; + +template class Pair { +public: + A first; + B second; + + Pair(const A &f): first(f) {} + Pair(const A &f, const B &s): first(f), second(s) {} + Pair(Pair &other): first(other.first), second(other.second) {} + virtual ~Pair() {} + + const bool operator<(const Pair &other) const {return first < other.first;} + const bool operator==(const Pair &other) const {return first == other.first;} + Pair &operator=(const Pair &other) {first = other.first; second = other.second; return *this;} +}; + +template class Map: public BinaryTree< Pair< A, B > > { +protected: + + const TreeNode > *find(A &val) const { + TreeNode > *n = BinaryTree< Pair< A, B > >::root; + while(n) { + if(n->val.first == val) + return n; + else if(val < n->val.first) + n = n->left; + else + n = n->right; + + } + return 0; + } +public: + Map(): BinaryTree< Pair >() {} + virtual ~Map() {} + + void put(A &key, B &value) { + add(Pair(key, value)); + } + + const bool get(A &key, B &val) const { + const TreeNode > *n = find(key); + if(n) { + val = n->val.second; + return true; + } else + return false; + } + + B &operator[](A &key) { + TreeNode > *n = find(key); + if(n) + return n->val.second; + else { + Pair< A, B > p(key); + TreeNode > *n = new TreeNode >(p, 0); + insert_node(n); + Collection< Pair< A, B > >::count++; + return n->val.second; + } + } + + const bool exists(A &key) const { + const TreeNode > *n = find(key); + if(n) { + return true; + } else + return false; + } + + const bool remove(A &key) { + TreeNode > *n = find(key); + if(n) { + delete_node(n); + return true; + } else + return false; + } +}; diff --git a/MySpace/common.cpp b/MySpace/common.cpp new file mode 100644 index 0000000..3324856 --- /dev/null +++ b/MySpace/common.cpp @@ -0,0 +1 @@ +#include "common.h" diff --git a/MySpace/common.h b/MySpace/common.h new file mode 100644 index 0000000..f80037c --- /dev/null +++ b/MySpace/common.h @@ -0,0 +1,67 @@ +#ifndef _COMMON_INC +#define _COMMON_INC + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows XP or later. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. +#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. +#endif + +#if defined( UNICODE ) && !defined( _UNICODE ) +#define _UNICODE +#endif + +#include + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include +#include + +#define MIRANDA_VER 0x0700 + +#include +#include +#include +#include +#include +#include +#include +#include // for m_utils +#include // for FD_SETSIZE +#include +#include + +#include + +//////////// +// included for backward compatibility +#ifndef CMIF_UNICODE +#define CMIF_UNICODE 512 //will return TCHAR* instead of char* +#if defined( _UNICODE ) + #define CMIF_TCHAR CMIF_UNICODE //will return TCHAR* instead of char* +#else + #define CMIF_TCHAR 0 //will return char*, as usual +#endif +#endif +//////////// + +#define MODULE "MySpace" + +extern HINSTANCE hInst; +extern PLUGINLINK *pluginLink; +extern HANDLE mainThread; + +#endif diff --git a/MySpace/icon1.ico b/MySpace/icon1.ico new file mode 100644 index 0000000..881674b Binary files /dev/null and b/MySpace/icon1.ico differ diff --git a/MySpace/menu.cpp b/MySpace/menu.cpp new file mode 100644 index 0000000..42c8ca9 --- /dev/null +++ b/MySpace/menu.cpp @@ -0,0 +1,75 @@ +#include "common.h" +#include "menu.h" +#include "resource.h" + +HANDLE hMenuMain = 0, hServiceMenuMain = 0; + +int MainMenuService(WPARAM wParam, LPARAM lParam) { + // TODO: add code here that executes when the menu item is chosen + + // e.g. modify main menu item - see m_clist.h + //CLISTMENUITEM menu = {0}; + //menu.cbSize=sizeof(menu); + //menu.flags = CMIM_NAME | CMIF_TCHAR; + //menu.ptszName = (char *)TranslateT("Changed menu text"); + //CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuMain, (LPARAM)&menu); + + return 0; +} + +HANDLE hMenuContact = 0, hServiceMenuContact = 0, hEventMenuBuild = 0; + +int ContactMenuService(WPARAM wParam, LPARAM lParam) { + HANDLE hContact = (HANDLE)wParam; + // TODO: add code here that executes when the menu item is chosen + + // e.g. you could modify the menu item here - see below + return 0; +} + +// this function is called when the contact's menu is about to be shown - you can e.g. +// modify the menu here using the MS_CLIST_MODIFYMENUITEM service +int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) { + HANDLE hContact = (HANDLE)wParam; + // TODO: add code here that executes when the menu is constructed + + // e.g. modify menu item - see m_clist.h + //CLISTMENUITEM menu = {0}; + //menu.cbSize=sizeof(menu); + //menu.flags = CMIM_NAME | CMIF_TCHAR; + //menu.ptszName = (char *)TranslateT("Changed menu text"); + //CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuContact, (LPARAM)&menu); + + return 0; +} + +void InitMenu() { + CLISTMENUITEM menu = {0}; + menu.cbSize=sizeof(menu); + + menu.flags = CMIM_ALL | CMIF_TCHAR; + menu.hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON_PROTO), IMAGE_ICON, 0, 0, 0); + + // main menu item + hServiceMenuMain = CreateServiceFunction(MODULE "/MainMenu", MainMenuService); + menu.ptszName = TranslateT(MODULE); + menu.pszService = MODULE "/MainMenu"; + menu.position = 0; + hMenuMain = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&menu); + + // contact menu item + hServiceMenuContact = CreateServiceFunction(MODULE "/ContactMenu", ContactMenuService); + menu.ptszName = TranslateT(MODULE); + menu.pszService = MODULE "/ContactMenu"; + menu.position = 0; + menu.flags = CMIF_NOTOFFLINE; // only show for not-offline contacts + hMenuContact = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&menu); + + hEventMenuBuild = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu); +} + +void DeinitMenu() { + UnhookEvent(hEventMenuBuild); + DestroyServiceFunction(hServiceMenuContact); + DestroyServiceFunction(hServiceMenuMain); +} \ No newline at end of file diff --git a/MySpace/menu.h b/MySpace/menu.h new file mode 100644 index 0000000..0add0ed --- /dev/null +++ b/MySpace/menu.h @@ -0,0 +1,7 @@ +#ifndef _MENU_INC +#define _MENU_INC + +void InitMenu(); +void DeinitMenu(); + +#endif diff --git a/MySpace/menu.ico b/MySpace/menu.ico new file mode 100644 index 0000000..94f62a2 Binary files /dev/null and b/MySpace/menu.ico differ diff --git a/MySpace/net.cpp b/MySpace/net.cpp new file mode 100644 index 0000000..812c551 --- /dev/null +++ b/MySpace/net.cpp @@ -0,0 +1,20 @@ +#include "common.h" +#include "net.h" + +HANDLE hNetlibUser = 0; + +void InitNetlib() { + NETLIBUSER nl_user = {0}; + nl_user.cbSize = sizeof(nl_user); + nl_user.szSettingsModule = MODULE; + nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS; + nl_user.szDescriptiveName = MODULE; + + hNetlibUser = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nl_user); +} + +void DeinitNetlib() { + if(hNetlibUser) + CallService(MS_NETLIB_CLOSEHANDLE, (WPARAM)hNetlibUser, 0); +} + diff --git a/MySpace/net.h b/MySpace/net.h new file mode 100644 index 0000000..886a19b --- /dev/null +++ b/MySpace/net.h @@ -0,0 +1,10 @@ +#ifndef _NET_INC +#define _NET_INC + +// uncomment this if you need access elsewhere +extern HANDLE hNetlibUser; + +void InitNetlib(); +void DeinitNetlib(); + +#endif \ No newline at end of file diff --git a/MySpace/options.cpp b/MySpace/options.cpp new file mode 100644 index 0000000..0da55b7 --- /dev/null +++ b/MySpace/options.cpp @@ -0,0 +1,89 @@ +#include "common.h" +#include "options.h" +#include "resource.h" + +Options options = {0}; + +void LoadOptions() { + DBVARIANT dbv; + if(!DBGetContactSettingTString(0, MODULE, "email", &dbv)) { + _tcsncpy(options.email, dbv.ptszVal, 256); + DBFreeVariant(&dbv); + } + if(!DBGetContactSettingTString(0, MODULE, "pw", &dbv)) { + _tcsncpy(options.pw, dbv.ptszVal, 256); + DBFreeVariant(&dbv); + } +} + +void SaveOptions() { + DBWriteContactSettingTString(0, MODULE, "email", options.email); + DBWriteContactSettingTString(0, MODULE, "pw", options.pw); +} + +BOOL CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + static HANDLE hItemAll; + + switch ( msg ) { + case WM_INITDIALOG: + TranslateDialogDefault( hwndDlg ); + SetDlgItemText(hwndDlg, IDC_ED_EMAIL, options.email); + SetDlgItemText(hwndDlg, IDC_ED_PW, options.pw); + return FALSE; + case WM_COMMAND: + if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) { + switch( LOWORD( wParam )) { + case IDC_ED_EMAIL: + case IDC_ED_PW: + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + break; + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) + { + case PSN_APPLY: + GetDlgItemText(hwndDlg, IDC_ED_EMAIL, options.email, 256); + GetDlgItemText(hwndDlg, IDC_ED_PW, options.pw, 256); + + SaveOptions(); + } + break; + } + break; + } + + return 0; +} + +int OptInit(WPARAM wParam, LPARAM lParam) { + OPTIONSDIALOGPAGE odp = { 0 }; + odp.cbSize = sizeof(odp); + odp.flags = ODPF_BOLDGROUPS; + odp.flags |= ODPF_TCHAR; + odp.position = -790000000; + odp.hInstance = hInst; + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT1); + odp.ptszTitle = TranslateT(MODULE); + odp.ptszGroup = TranslateT("Network"); + odp.ptszTab = TranslateT("Account"); + odp.nIDBottomSimpleControl = 0; + odp.pfnDlgProc = DlgProcOpts; + CallService( MS_OPT_ADDPAGE, wParam,( LPARAM )&odp ); + + return 0; +} + +HANDLE hEventOptInit; +void InitOptions() { + hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit); + LoadOptions(); +} + +void DeinitOptions() { + UnhookEvent(hEventOptInit); +} diff --git a/MySpace/options.h b/MySpace/options.h new file mode 100644 index 0000000..2aea34c --- /dev/null +++ b/MySpace/options.h @@ -0,0 +1,14 @@ +#ifndef _OPTIONS_INC +#define _OPTIONS_INC + +typedef struct { + TCHAR email[256]; + TCHAR pw[256]; +} Options; + +extern Options options; + +void InitOptions(); +void DeinitOptions(); + +#endif diff --git a/MySpace/proto.cpp b/MySpace/proto.cpp new file mode 100644 index 0000000..4b3aa00 --- /dev/null +++ b/MySpace/proto.cpp @@ -0,0 +1,153 @@ +#include "common.h" +#include "proto.h" +#include "server_con.h" +#include "resource.h" + +#define MAX_MESSAGE_SIZE 1024 + +int GetCaps(WPARAM wParam,LPARAM lParam) { + int ret = 0; + switch (wParam) { + case PFLAGNUM_1: + //ret = PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_MODEMSG | PF1_FILE | PF1_CHAT; + ret = PF1_IM;// | PF1_BASICSEARCH | PF1_EXTSEARCHUI | PF1_ADDSEARCHRES | PF1_MODEMSG | PF1_FILE | PF1_CHAT; + break; + case PFLAGNUM_2: + ret = PF2_ONLINE;// | PF2_SHORTAWAY | PF2_HEAVYDND; + break; + case PFLAGNUM_3: + //ret = PF2_ONLINE;// | PF2_SHORTAWAY | PF2_HEAVYDND; + break; + case PFLAGNUM_4: + //ret = PF4_SUPPORTTYPING; + break; + case PFLAG_UNIQUEIDTEXT: + ret = (int) Translate("UserID"); + break; + case PFLAG_MAXLENOFMESSAGE: + ret = MAX_MESSAGE_SIZE; + break; + case PFLAG_UNIQUEIDSETTING: + ret = (int) "UID"; + break; + } + return ret; +} + +int GetName(WPARAM wParam,LPARAM lParam) { + mir_snprintf((char *)lParam, wParam, "%s", MODULE); + return 0; +} + +int LoadIcon(WPARAM wParam,LPARAM lParam) { + + UINT id; + switch (wParam & 0xFFFF) + { + case PLI_PROTOCOL: + id = IDI_ICON_PROTO; + break; + case PLI_ONLINE: + id = IDI_ICON_PROTO; + break; + case PLI_OFFLINE: + id = IDI_ICON_PROTO; + break; + 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); + return 0; +} + +int GetInfo(WPARAM wParam,LPARAM lParam) { + return 0; +} + +int SetStatus(WPARAM wParam,LPARAM lParam) { + if(wParam != ID_STATUS_OFFLINE) + InitServerConnection(); + else + DeinitServerConnection(); + return 0; +} + +int GetStatus(WPARAM wParam,LPARAM lParam) { + return status; +} + +int ProtoSendMessage(WPARAM wParam, LPARAM lParam) { + CCSDATA *ccs = (CCSDATA *) lParam; + char *message = (char *)ccs->lParam; + + // TODO: process 'message' and/or 'messagew' below + if(ccs->wParam & PREF_UNICODE) { + wchar_t *messagew = (wchar_t *)&message[strlen(message)+1]; + } else if(ccs->wParam & PREF_UTF) { + // message is utf8 encoded - you can use mir_utf8decode (m_system.h) to make it wide + } else { + } + + return CallService(MS_PROTO_CHAINSEND, wParam, lParam); +} + +int ProtoSendMessageW(WPARAM wParam, LPARAM lParam) { + CCSDATA *ccs = (CCSDATA *) lParam; + ccs->wParam |= PREF_UNICODE; + + return ProtoSendMessage(wParam, lParam); +} + +int ProtoRecvMessage(WPARAM wParam, LPARAM lParam) { + CCSDATA *ccs = (CCSDATA *) lParam; + PROTORECVEVENT *pre = (PROTORECVEVENT *) ccs->lParam; + + char *message = pre->szMessage; + + // TODO: process 'message' and/or 'messagew' below + if(pre->flags & PREF_UNICODE) { + wchar_t *messagew = (wchar_t *)&message[strlen(message)+1]; + } else if(pre->flags & PREF_UTF) { + // message is utf8 encoded - you can use mir_utf8decode (m_system.h) to make it wide + } + + return CallService(MS_PROTO_CHAINRECV, wParam, lParam); +} + + + +void RegisterProto() { + PROTOCOLDESCRIPTOR pd = {0}; + pd.cbSize = sizeof(pd); + pd.szName = MODULE; + pd.type = PROTOTYPE_PROTOCOL; + CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd); +} + +#define NUM_FILTER_SERVICES 9 +HANDLE hServices[NUM_FILTER_SERVICES]; + +void CreateProtoServices() { + // create our services + int i = 0; + hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_MESSAGE, ProtoSendMessage); + hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_MESSAGE"W", ProtoSendMessageW); + hServices[i++] = CreateProtoServiceFunction(MODULE, PSR_MESSAGE, ProtoRecvMessage); + + hServices[i++] = CreateProtoServiceFunction(MODULE, PS_GETCAPS, GetCaps); + hServices[i++] = CreateProtoServiceFunction(MODULE, PS_GETNAME, GetName); + hServices[i++] = CreateProtoServiceFunction(MODULE, PS_LOADICON,LoadIcon); + hServices[i++] = CreateProtoServiceFunction(MODULE, PSS_GETINFO,GetInfo); + hServices[i++] = CreateProtoServiceFunction(MODULE, PS_SETSTATUS, SetStatus); + hServices[i++] = CreateProtoServiceFunction(MODULE, PS_GETSTATUS, GetStatus); + + // remember to modify the NUM_FILTER_SERVICES #define above if you add more services! +} + +void DeinitProto() { + for(int i = 0; i < NUM_FILTER_SERVICES; i++) + DestroyServiceFunction(hServices[i]); +} \ No newline at end of file diff --git a/MySpace/proto.h b/MySpace/proto.h new file mode 100644 index 0000000..d45c485 --- /dev/null +++ b/MySpace/proto.h @@ -0,0 +1,8 @@ +#ifndef _PROTO_INC +#define _PROTO_INC + +void RegisterProto(); +void CreateProtoServices(); +void DeinitProto(); + +#endif diff --git a/MySpace/readme.txt b/MySpace/readme.txt new file mode 100644 index 0000000..d649f60 --- /dev/null +++ b/MySpace/readme.txt @@ -0,0 +1,47 @@ +======================================================================== + Miranda Plugin : MySpace Project Overview +======================================================================== + +Miranda Plugin has created this MySpace project for you as a starting point. + +This file contains a summary of what you will find in each of the files that make up your project. + +MySpace.vcproj + This is the main project file for projects generated using an Application Wizard. + It contains information about the version of the product that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +MySpace.cpp + Main plugin file. Contains the functions necessary for the plugin to load. + +MySpace.rc + Project resources - this is the the only resource file that should require editing on your part! + This file contains for example the options dialog page. + +version.h + Version information + +version.rc + Version resource - do not edit! + +common.h + Common includes - also acts as the procompiled header file for the project. + +common.cpp + Just includes the common.h header file. + +resource.h + Resource defines + +resource.rc + Binds together the version and plugin resources - do not edit! + +options.cpp +options.h + These files contain the dialog procedure for the options page, and placeholders for options including save and load routines. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +///////////////////////////////////////////////////////////////////////////// diff --git a/MySpace/resource.h b/MySpace/resource.h new file mode 100644 index 0000000..a9d9bb1 --- /dev/null +++ b/MySpace/resource.h @@ -0,0 +1,21 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by MySpace.rc +// +#define IDD_OPT1 109 +#define IDI_MENU 110 +#define IDI_ICON1 120 +#define IDI_ICON_PROTO 120 +#define IDC_ED_EMAIL 1001 +#define IDC_ED_PW 1002 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 121 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1002 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/MySpace/resource.rc b/MySpace/resource.rc new file mode 100644 index 0000000..949b789 --- /dev/null +++ b/MySpace/resource.rc @@ -0,0 +1,2 @@ +#include "version.rc" +#include "MySpace.rc" diff --git a/MySpace/server_con.cpp b/MySpace/server_con.cpp new file mode 100644 index 0000000..f3c6d79 --- /dev/null +++ b/MySpace/server_con.cpp @@ -0,0 +1,124 @@ +#include "common.h" +#include "server_con.h" +#include "net.h" + +#include "NetMessage.h" + +#define SERVER_READ_BUFFER_SIZE (1024 * 32) + +int status = ID_STATUS_OFFLINE; +bool server_running = false, server_stop = false; +HANDLE server_connection = 0; + +void CALLBACK sttMainThreadStatusCallback( ULONG dwParam ) { + if(status != dwParam) { + int previous_status = status; + status = dwParam; + ProtoBroadcastAck(MODULE,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS, (HANDLE)previous_status, status); + } +} + +int waitcallback(unsigned int *timeout) { + PUShowMessage("waitcallback", SM_NOTIFY); + return server_stop ? 0 : 1; +} + +int try_ports[9] = {1863, 6660,6661,6662,6665,6668,6669,80,0443}; + +void __cdecl ServerThreadFunc(void*) { + NETLIBOPENCONNECTION conn_data = {0}; + conn_data.cbSize = sizeof(NETLIBOPENCONNECTION); + conn_data.flags = NLOCF_V2; + conn_data.szHost = "im.myspace.akadns.net"; + conn_data.wPort = DBGetContactSettingDword(0, MODULE, "LastPort", try_ports[0]); + conn_data.timeout = 10; + conn_data.waitcallback = waitcallback; + + QueueUserAPC(sttMainThreadStatusCallback, mainThread, ID_STATUS_CONNECTING); + + server_running = true; + + char *recv_buffer = new char[SERVER_READ_BUFFER_SIZE]; + int bytes = 0; + char mt[256]; + int tries = 0; + bool login = true; + + while(!Miranda_Terminated() && !server_stop) { + if(login) { + if(server_connection) Netlib_CloseHandle(server_connection); + server_connection = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&conn_data); + } + bytes = Netlib_Recv(server_connection, (char *)recv_buffer, SERVER_READ_BUFFER_SIZE, MSG_DUMPASTEXT); + + if(bytes == 0) { + PUShowMessage("Connection closed", SM_NOTIFY); + if(login && tries < 9) { + conn_data.wPort = try_ports[tries++]; + } else + break; + } else if(bytes == SOCKET_ERROR) { + PUShowMessage("Socket ERROR", SM_NOTIFY); + break; + } else { + if(login) { + login = false; + QueueUserAPC(sttMainThreadStatusCallback, mainThread, ID_STATUS_ONLINE); + } + + mir_snprintf(mt, 256, "recvd %d bytes", bytes); + PUShowMessage(mt, SM_NOTIFY); + + NetMessage msg; + msg.parse(recv_buffer, bytes); + if(msg.exists(NMString("lc"))) { + NMString val; + msg.get(NMString("lc"), val); + mir_snprintf(mt, 256, "Login message: type is %s", val.text); + PUShowMessage(mt, SM_NOTIFY); + // challenge/response: + // + } else if(msg.exists(NMString("persistr"))) { + NMString cmd, dsn, lid; + msg.get(NMString("cmd"), cmd); + msg.get(NMString("dsn"), dsn); + msg.get(NMString("lid"), lid); + mir_snprintf(mt, 256, "Perist message: type is %s,%s,%s", cmd.text, dsn.text, lid.text); + PUShowMessage(mt, SM_NOTIFY); + } + } + } + if(server_connection) { + Netlib_CloseHandle(server_connection); + server_connection = 0; + } + delete recv_buffer; + + QueueUserAPC(sttMainThreadStatusCallback, mainThread, ID_STATUS_OFFLINE); + server_running = false; +} + +void StartThread() { + if(!server_running) { + server_stop = false; + mir_forkthread(ServerThreadFunc, 0); + } +} + +void StopThread() { + if(server_running) { + server_stop = true; + if(server_connection) { + Netlib_CloseHandle(server_connection); + server_connection = 0; + } + } +} + +void InitServerConnection() { + StartThread(); +} + +void DeinitServerConnection() { + StopThread(); +} diff --git a/MySpace/server_con.h b/MySpace/server_con.h new file mode 100644 index 0000000..e051f87 --- /dev/null +++ b/MySpace/server_con.h @@ -0,0 +1,9 @@ +#ifndef _SERVER_CON_INC +#define _SERVER_CON_INC + +extern int status; + +void InitServerConnection(); +void DeinitServerConnection(); + +#endif diff --git a/MySpace/version.h b/MySpace/version.h new file mode 100644 index 0000000..d9c3688 --- /dev/null +++ b/MySpace/version.h @@ -0,0 +1,26 @@ +// Set the version number here - it will affect the version resource and the version field of the pluginInfo structure +// (Be careful that you don't have the resource file open when you change this and rebuild, otherwise the changes may not +// take effect within the version resource) + +#define __MAJOR_VERSION 0 +#define __MINOR_VERSION 0 +#define __RELEASE_NUM 0 +#define __BUILD_NUM 1 + +#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM +#define __FILEVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM +#define __STRINGIFY(x) #x +#define __VERSION_STRING __STRINGIFY(__FILEVERSION_STRING_DOTS) + +#ifdef _UNICODE +#define __PLUGIN_NAME "MySpace (Unicode)" +#else +#define __PLUGIN_NAME "MySpace" +#endif +#define __FILENAME "MySpace.dll" + +#define __DESC "MySpace IM protocol" +#define __AUTHOR "Scott Ellis" +#define __AUTHOREMAIL "mail@scottellis.com.au" +#define __AUTHORWEB "http://www.scottellis.com.au" +#define __COPYRIGHT "© 2007 Scott Ellis" diff --git a/MySpace/version.rc b/MySpace/version.rc new file mode 100644 index 0000000..0bb7a49 --- /dev/null +++ b/MySpace/version.rc @@ -0,0 +1,33 @@ + +#include +#include "version.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION __FILEVERSION_STRING + PRODUCTVERSION __FILEVERSION_STRING + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "000004b0" + BEGIN + VALUE "Author", __AUTHOR + VALUE "FileDescription", __DESC + VALUE "InternalName", __PLUGIN_NAME + VALUE "LegalCopyright", __COPYRIGHT + VALUE "OriginalFilename", __FILENAME + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1200 + END +END -- cgit v1.2.3