diff options
-rw-r--r-- | Plugins/emoticons/Docs/emoticons_changelog.txt | 2 | ||||
-rw-r--r-- | Plugins/emoticons/Docs/emoticons_readme.txt | 6 | ||||
-rw-r--r-- | Plugins/emoticons/commons.h | 20 | ||||
-rw-r--r-- | Plugins/emoticons/emoticons.cpp | 384 | ||||
-rw-r--r-- | Plugins/emoticons/options.cpp | 9 | ||||
-rw-r--r-- | Plugins/emoticons/options.h | 1 | ||||
-rw-r--r-- | Plugins/emoticons/resource.h | 4 | ||||
-rw-r--r-- | Plugins/emoticons/resource.rc | 53 | ||||
-rw-r--r-- | Plugins/emoticons/sdk/m_customsmileys.h | 52 | ||||
-rw-r--r-- | Plugins/emoticons/sdk/m_smileyadd.h | 27 |
10 files changed, 206 insertions, 352 deletions
diff --git a/Plugins/emoticons/Docs/emoticons_changelog.txt b/Plugins/emoticons/Docs/emoticons_changelog.txt index 6009fba..51f9dfa 100644 --- a/Plugins/emoticons/Docs/emoticons_changelog.txt +++ b/Plugins/emoticons/Docs/emoticons_changelog.txt @@ -5,6 +5,8 @@ Changelog: . 0.0.1.3
* Fix for protocol emoticons (closes issue 22)
* Fix for URLs in input area
+ + Support for borkra's version of custom smileys
+ + Option to disable custom smileys
. 0.0.1.2
* Fix for wrong memory free
diff --git a/Plugins/emoticons/Docs/emoticons_readme.txt b/Plugins/emoticons/Docs/emoticons_readme.txt index 9051f36..824bfac 100644 --- a/Plugins/emoticons/Docs/emoticons_readme.txt +++ b/Plugins/emoticons/Docs/emoticons_readme.txt @@ -37,6 +37,8 @@ or A default pack, containing Tango Emoticons (made by Hylke) is packed and can be used as an example.
+For custom smileys to work, you need MSN protocol from miranda 0.8 #10.
+
Currently there is a lot more work to be done on this plugin, but I wanted to show an initial version, so I could get some feedback.
Thanks to FYR for the AniSmiley plugin and to Hylke for the nice emoticons.
@@ -49,7 +51,3 @@ TODO: - Updater support for Emoticon Packs
- Support h++ (works using AniSmiley)
-
-KNOWN ISSUES:
-- AniSmiley does not resize itself when receiving custom smiley
-
diff --git a/Plugins/emoticons/commons.h b/Plugins/emoticons/commons.h index c132f89..f924b9d 100644 --- a/Plugins/emoticons/commons.h +++ b/Plugins/emoticons/commons.h @@ -68,7 +68,7 @@ using namespace std; #include <m_anismiley.h>
#include <anismiley.tlh>
#include <m_smileyadd.h>
-#include <m_customsmileys.h>
+#include <m_netlib.h>
#include "../utils/mir_memory.h"
#include "../utils/mir_options.h"
@@ -89,7 +89,7 @@ using namespace std; extern HINSTANCE hInst;
extern PLUGINLINK *pluginLink;
extern FI_INTERFACE *fei;
-
+extern HANDLE hChangedEvent;
#define MIR_FREE(_X_) { mir_free(_X_); _X_ = NULL; }
#define MAX_REGS(_A_) ( sizeof(_A_) / sizeof(_A_[0]) )
@@ -116,6 +116,7 @@ struct EmoticonImage BOOL isAvaiableFor(char *nodule);
};
+
struct Emoticon
{
char *name;
@@ -130,24 +131,16 @@ struct Emoticon ~Emoticon();
};
+
struct CustomEmoticon
{
TCHAR *text;
char *path;
- BOOL downloading;
+ DWORD firstReceived;
- CustomEmoticon() : text(0), path(0), downloading(FALSE) {}
+ CustomEmoticon() : text(0), path(0), firstReceived(0) {}
};
-struct DowloadingEmoticon
-{
- char *path;
- void *img;
-
- DowloadingEmoticon() : path(0), img(0) {}
- ~DowloadingEmoticon();
- void Downloaded();
-};
struct Module
{
@@ -173,6 +166,7 @@ struct EmoticonPack ~EmoticonPack();
};
+
struct RichEditCtrl
{
HWND hwnd;
diff --git a/Plugins/emoticons/emoticons.cpp b/Plugins/emoticons/emoticons.cpp index f100180..ffb44e5 100644 --- a/Plugins/emoticons/emoticons.cpp +++ b/Plugins/emoticons/emoticons.cpp @@ -50,7 +50,8 @@ HINSTANCE hInst; PLUGINLINK *pluginLink;
HANDLE hHooks[3] = {0};
-HANDLE hServices[3] = {0};
+HANDLE hServices[4] = {0};
+HANDLE hChangedEvent;
HANDLE hProtocolsFolder = NULL;
TCHAR protocolsFolder[1024];
@@ -72,7 +73,6 @@ FI_INTERFACE *fei = NULL; LIST<Module> modules(10);
LIST<EmoticonPack> packs(10);
LIST<Contact> contacts(10);
-LIST<DowloadingEmoticon> downloading(10);
BOOL LoadModule(Module *m);
void LoadModules();
@@ -91,11 +91,11 @@ void ReleaseModuleImage(EmoticonImage *img); int ModulesLoaded(WPARAM wParam, LPARAM lParam);
int PreShutdown(WPARAM wParam, LPARAM lParam);
int MsgWindowEvent(WPARAM wParam, LPARAM lParam);
-int CustomSmileyReceivedEvent(WPARAM wParam, LPARAM lParam);
int ReplaceEmoticonsService(WPARAM wParam, LPARAM lParam);
int GetInfo2Service(WPARAM wParam, LPARAM lParam);
int ShowSelectionService(WPARAM wParam, LPARAM lParam);
+int LoadContactSmileysService(WPARAM wParam, LPARAM lParam);
TCHAR *GetText(RichEditCtrl &rec, int start, int end);
@@ -203,10 +203,13 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) mir_getLI(&li);
CallService(MS_IMG_GETINTERFACE, FI_IF_VERSION, (LPARAM) &fei);
- // hooks
hHooks[0] = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
hHooks[1] = HookEvent(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+ hServices[0] = CreateServiceFunction(MS_SMILEYADD_LOADCONTACTSMILEYS, LoadContactSmileysService);
+
+ hChangedEvent = CreateHookableEvent(ME_SMILEYADD_OPTIONSCHANGED);
+
return 0;
}
@@ -299,26 +302,9 @@ int ModulesLoaded(WPARAM wParam, LPARAM lParam) hHooks[2] = HookEvent(ME_MSG_WINDOWEVENT, &MsgWindowEvent);
- hServices[0] = CreateServiceFunction(MS_SMILEYADD_REPLACESMILEYS, ReplaceEmoticonsService);
- hServices[1] = CreateServiceFunction(MS_SMILEYADD_GETINFO2, GetInfo2Service);
- hServices[2] = CreateServiceFunction(MS_SMILEYADD_SHOWSELECTION, ShowSelectionService);
-
- // Hook custom emoticons notification
- PROTOCOLDESCRIPTOR **protos;
- int count;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos);
- for (int i = 0; i < count; i++)
- {
- if (protos[i]->type != PROTOTYPE_PROTOCOL)
- continue;
-
- if (protos[i]->szName == NULL || protos[i]->szName[0] == '\0')
- continue;
-
- char evname[250];
- mir_snprintf(evname, MAX_REGS(evname), "%s%s", protos[i]->szName, ME_CUSTOMSMILEY_RECEIVED);
- HookEvent(evname, &CustomSmileyReceivedEvent);
- }
+ hServices[1] = CreateServiceFunction(MS_SMILEYADD_REPLACESMILEYS, ReplaceEmoticonsService);
+ hServices[2] = CreateServiceFunction(MS_SMILEYADD_GETINFO2, GetInfo2Service);
+ hServices[3] = CreateServiceFunction(MS_SMILEYADD_SHOWSELECTION, ShowSelectionService);
loaded = TRUE;
@@ -330,12 +316,6 @@ int PreShutdown(WPARAM wParam, LPARAM lParam) {
int i;
- for(i = downloading.getCount() - 1; i >= 0; i--)
- {
- delete downloading[i];
- downloading.remove(i);
- }
-
// Delete packs
for(i = 0; i < packs.getCount(); i++)
{
@@ -400,7 +380,6 @@ int ReplaceEmoticonBackwards(RichEditCtrl &rec, Contact *contact, Module *module char found_path[1024];
int found_len = -1;
TCHAR *found_text;
- BOOL found_downloading = FALSE;
// Replace normal emoticons
if (!opts.only_replace_isolated || next_char == _T('\0') || _istspace(next_char))
@@ -436,7 +415,7 @@ int ReplaceEmoticonBackwards(RichEditCtrl &rec, Contact *contact, Module *module }
// Replace custom smileys
- if (contact != NULL)
+ if (contact != NULL && opts.enable_custom_smileys)
{
for(int i = 0; i < contact->emoticons.getCount(); i++)
{
@@ -456,7 +435,6 @@ int ReplaceEmoticonBackwards(RichEditCtrl &rec, Contact *contact, Module *module mir_snprintf(found_path, MAX_REGS(found_path), "%s", e->path);
found_len = len;
found_text = txt;
- found_downloading = e->downloading;
}
}
@@ -482,64 +460,17 @@ int ReplaceEmoticonBackwards(RichEditCtrl &rec, Contact *contact, Module *module SendMessage(rec.hwnd, EM_SETBKGNDCOLOR, 0, cf.crBackColor);
}
- DowloadingEmoticon *de = NULL;
- if (found_downloading)
- {
- de = new DowloadingEmoticon();
- de->path = mir_strdup(found_path);
-
- mir_snprintf(found_path, MAX_REGS(found_path), TCHAR_STR_PARAM "\\downloading.gif", protocolsFolder);
- }
-
TCHAR *path = mir_a2t(found_path);
- IUnknown * gctrl;
- if (gctrl = (IGifSmileyCtrl *) InsertAnimatedSmiley(rec.hwnd, path, cf.crBackColor, 0 , found_text))
+ if (InsertAnimatedSmiley(rec.hwnd, path, cf.crBackColor, 0 , found_text))
{
ret = - found_len + 1;
}
MIR_FREE(path);
-
- if (found_downloading)
- {
- if (gctrl == NULL)
- {
- delete de;
- }
- else
- {
- IGifSmileyCtrl * igsc;
- if (gctrl->QueryInterface(__uuidof(IGifSmileyCtrl), (void **) &igsc) != S_OK || igsc == NULL)
- {
- delete de;
- }
- else
- {
- de->img = igsc;
- downloading.insert(de);
- }
- }
- }
}
else
{
- DowloadingEmoticon *de = NULL;
- if (found_downloading)
- {
- de = new DowloadingEmoticon();
- de->path = mir_strdup(found_path);
-
- mir_snprintf(found_path, MAX_REGS(found_path), TCHAR_STR_PARAM "\\downloading.gif", protocolsFolder);
- }
-
OleImage *img = new OleImage(found_path, found_text, found_text);
-
- if (found_downloading)
- {
- de->img = img;
- img->AddRef();
- downloading.insert(de);
- }
- else if (!img->isValid())
+ if (!img->isValid())
{
delete img;
return 0;
@@ -1071,13 +1002,7 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) Dialog *dlg = dlgit->second;
-/* int old_len;
- if (msg == DM_APPENDTOLOG)
- {
- old_len = GetWindowTextLength(dlg->log.hwnd);
- }
- else */
- if (msg == WM_COMMAND && LOWORD(wParam) == IDOK && dlg->input.old_edit_proc != NULL)
+ if (msg == WM_COMMAND && (LOWORD(wParam) == IDOK || LOWORD(wParam) == 1624) && dlg->input.old_edit_proc != NULL)
{
dlg->log.sending = TRUE;
@@ -1094,7 +1019,7 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
case WM_COMMAND:
{
- if (LOWORD(wParam) == IDOK)
+ if (LOWORD(wParam) == IDOK || LOWORD(wParam) == 1624)
{
if (!ret)
// Add emoticons again
@@ -1104,55 +1029,6 @@ LRESULT CALLBACK OwnerProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
break;
}
-/*
- case DM_APPENDTOLOG:
- {
- break;
-
- STOP_RICHEDIT(dlg->log);
-
- TCHAR *text = GetText(dlg->log, old_len, -1);
- int len = lstrlen(text);
-
- for(int i = len; i > 0; i--)
- {
- int dif = ReplaceEmoticonBackwards(dlg->log.hwnd, text, i, old_len + i, dlg->module);
-
- FixSelection(__old_sel.cpMax, i, dif);
- FixSelection(__old_sel.cpMin, i, dif);
- }
-
- MIR_FREE(text);
-
- START_RICHEDIT(dlg->log);
-
- break;
- }
-
- case DM_REMAKELOG:
- {
- break;
-
- STOP_RICHEDIT(dlg->log);
-
- TCHAR *text = GetText(dlg->log, 0, -1);
- int len = lstrlen(text);
-
- for(int i = len; i > 0; i--)
- {
- int dif = ReplaceEmoticonBackwards(dlg->log.hwnd, text, i, i, dlg->module);
-
- FixSelection(__old_sel.cpMax, i, dif);
- FixSelection(__old_sel.cpMin, i, dif);
- }
-
- MIR_FREE(text);
-
- START_RICHEDIT(dlg->log);
-
- break;
- }
-*/
}
return ret;
@@ -2070,48 +1946,6 @@ void EmoticonImage::Release() }
-DowloadingEmoticon::~DowloadingEmoticon()
-{
- MIR_FREE(path);
-
- if (img != NULL)
- {
- if (has_anismiley)
- ((IGifSmileyCtrl *) img)->Release();
- else
- ((OleImage *) img)->Release();
-
- img = NULL;
- }
-}
-
-
-void DowloadingEmoticon::Downloaded()
-{
- if (img == NULL)
- return;
-
- if (has_anismiley)
- {
- IGifSmileyCtrl *igsc = (IGifSmileyCtrl *) img;
-
- WCHAR *p = mir_a2u(path);
- BSTR bp = SysAllocString(p);
- igsc->LoadFromFile(bp);
- SysFreeString(bp);
- mir_free(p);
-
- igsc->Release();
- }
- else
- {
- OleImage *oimg = (OleImage *) img;
- oimg->SetFilename(path);
- oimg->Release();
- }
-
- img = NULL;
-}
Contact * GetContact(HANDLE hContact)
@@ -2148,6 +1982,9 @@ Contact * GetContact(HANDLE hContact) DBFreeVariant(&dbv_text);
continue;
}
+
+ mir_snprintf(setting, MAX_REGS(setting), "%d_FirstReceived", c->lastId);
+ DWORD firstReceived = DBGetContactSettingDword(hContact, "CustomSmileys", setting, 0);
if (!FileExists(dbv_path.pszVal))
{
@@ -2162,6 +1999,7 @@ Contact * GetContact(HANDLE hContact) CustomEmoticon *ce = new CustomEmoticon();
ce->text = mir_tstrdup(dbv_text.ptszVal);
ce->path = mir_strdup(dbv_path.pszVal);
+ ce->firstReceived = firstReceived;
c->emoticons.insert(ce);
}
@@ -2185,6 +2023,9 @@ Contact * GetContact(HANDLE hContact) mir_snprintf(setting, MAX_REGS(setting), "%d_Path", i);
DBWriteContactSettingString(c->hContact, "CustomSmileys", setting, ce->path);
+
+ mir_snprintf(setting, MAX_REGS(setting), "%d_FirstReceived", i);
+ DBWriteContactSettingDword(c->hContact, "CustomSmileys", setting, ce->firstReceived);
}
for(int j = i; j <= c->lastId; j++)
{
@@ -2193,6 +2034,9 @@ Contact * GetContact(HANDLE hContact) mir_snprintf(setting, MAX_REGS(setting), "%d_Path", j);
DBDeleteContactSetting(c->hContact, "CustomSmileys", setting);
+
+ mir_snprintf(setting, MAX_REGS(setting), "%d_FirstReceived", j);
+ DBDeleteContactSetting(c->hContact, "CustomSmileys", setting);
}
c->lastId = i - 1;
@@ -2213,98 +2057,150 @@ CustomEmoticon *GetCustomEmoticon(Contact *c, TCHAR *text) }
-void DownloadedCustomEmoticon(HANDLE hContact, const char *path)
+int SingleHexToDecimal(char c)
{
- // Mark that it was received
+ if ( c >= '0' && c <= '9' ) return c-'0';
+ if ( c >= 'a' && c <= 'f' ) return c-'a'+10;
+ if ( c >= 'A' && c <= 'F' ) return c-'A'+10;
+ return -1;
+}
- Contact *c = GetContact(hContact);
- if (c != NULL)
- {
- for(int i = 0; i < c->emoticons.getCount(); i++)
- {
- CustomEmoticon *ce = c->emoticons[i];
- if (stricmp(ce->path, path) == 0)
- ce->downloading = FALSE;
- }
- }
- for(int i = downloading.getCount() - 1; i >= 0; i--)
+void UrlDecode(char* str)
+{
+ char* s = str, *d = str;
+
+ while( *s )
{
- DowloadingEmoticon *de = downloading[i];
- if (stricmp(de->path, path) == 0)
- {
- de->Downloaded();
- delete de;
- downloading.remove(i);
- }
+ if ( *s == '%' ) {
+ int digit1 = SingleHexToDecimal( s[1] );
+ if ( digit1 != -1 ) {
+ int digit2 = SingleHexToDecimal( s[2] );
+ if ( digit2 != -1 ) {
+ s += 3;
+ *d++ = (char)(( digit1 << 4 ) | digit2);
+ continue;
+ } } }
+ *d++ = *s++;
}
+
+ *d = 0;
}
-int CustomSmileyReceivedEvent(WPARAM wParam, LPARAM lParam)
+
+void CreateCustomSmiley(Contact *contact, TCHAR *fullpath)
{
- CUSTOMSMILEY *cs = (CUSTOMSMILEY *) lParam;
- if (cs == NULL || cs->cbSize < sizeof(CUSTOMSMILEY) || cs->pszFilename == NULL || cs->hContact == NULL)
- return 0;
+ char *path = mir_t2a(fullpath);
- TCHAR log[1024];
- mir_sntprintf(log, 1024, _T("---------------\nReceived message: %d\n%S\n%s\n---------------\n"), cs->flags, cs->pszFilename, cs->ptszText);
- OutputDebugString(log);
+ // Get smiley text
+ char enc[1024];
+ char *start = strrchr(path, '\\');
+ if (start == NULL)
+ return;
+ start++;
+ char *end = strrchr(path, '.');
+ if (end == NULL || end < start)
+ return;
+ size_t enclen = min(end - start, MAX_REGS(enc));
+ strncpy(enc, start, enclen);
+ enc[enclen] = '\0';
- // Check if this is the second notification
- if (!(cs->flags & CUSTOMSMILEY_STATE_RECEIVED))
- {
- if (cs->flags & CUSTOMSMILEY_STATE_DOWNLOADED)
- DownloadedCustomEmoticon(cs->hContact, cs->pszFilename);
- return 0;
- }
+ UrlDecode(enc);
- // This is the first one
- if (cs->pszText == NULL)
- return 0;
+ enclen = strlen(enc);
+ size_t len = Netlib_GetBase64DecodedBufferSize(enclen) + 1;
+ char *tmp = (char *) malloc(len * sizeof(char));
- // Get data
- Contact *c = GetContact(cs->hContact);
+ NETLIBBASE64 nlb = { enc, enclen, (PBYTE) tmp, len };
+ if (CallService(MS_NETLIB_BASE64DECODE, 0, (LPARAM) &nlb) == 0)
+ return;
+ tmp[nlb.cbDecoded] = 0;
- TCHAR *text;
- if (cs->flags & CUSTOMSMILEY_UNICODE)
- text = mir_u2t(cs->pwszText);
- else
- text = mir_a2t(cs->pszText);
+#ifdef _UNICODE
+ TCHAR *text = mir_utf8decodeW(tmp);
+#else
+ mir_utf8decode(tmp, NULL);
+ TCHAR *text = mir_a2t(tmp);
+#endif
+
+ free(tmp);
// Create it
- CustomEmoticon *ce = GetCustomEmoticon(c, text);
+ CustomEmoticon *ce = GetCustomEmoticon(contact, text);
if (ce != NULL)
{
MIR_FREE(ce->path);
- ce->path = mir_strdup(cs->pszFilename);
-
- MIR_FREE(text);
+ ce->path = path;
}
else
{
ce = new CustomEmoticon();
ce->text = text;
- ce->path = mir_strdup(cs->pszFilename);
+ ce->path = path;
- c->emoticons.insert(ce);
- c->lastId++;
- }
-
- // Check if need to download
- if (!(cs->flags & CUSTOMSMILEY_STATE_DOWNLOADED) && !FileExists(cs->pszFilename))
- {
- // Request emoticon download
- cs->download = TRUE;
- ce->downloading = TRUE;
+ contact->emoticons.insert(ce);
+ contact->lastId++;
}
// Store in DB
char setting[256];
- mir_snprintf(setting, MAX_REGS(setting), "%d_Text", c->lastId);
- DBWriteContactSettingTString(c->hContact, "CustomSmileys", setting, ce->text);
+ mir_snprintf(setting, MAX_REGS(setting), "%d_Text", contact->lastId);
+ DBWriteContactSettingTString(contact->hContact, "CustomSmileys", setting, ce->text);
+
+ mir_snprintf(setting, MAX_REGS(setting), "%d_Path", contact->lastId);
+ DBWriteContactSettingString(contact->hContact, "CustomSmileys", setting, ce->path);
+
+ mir_snprintf(setting, MAX_REGS(setting), "%d_FirstReceived", contact->lastId);
+ DBWriteContactSettingDword(contact->hContact, "CustomSmileys", setting, (DWORD) time(NULL));
+
+ NotifyEventHooks(hChangedEvent, (WPARAM) contact->hContact, 0);
+}
+
+
+int LoadContactSmileysService(WPARAM wParam, LPARAM lParam)
+{
+ SMADD_CONT *sc = (SMADD_CONT *) lParam;
+ if (sc == NULL || sc->cbSize < sizeof(SMADD_CONT) || sc->path == NULL || sc->hContact == NULL || sc->type < 0 || sc->type > 1)
+ return 0;
+
+ Contact *c = GetContact(sc->hContact);
+
+ if (sc->type == 0)
+ {
+ TCHAR filename[1024];
+ mir_sntprintf(filename, MAX_REGS(filename), _T("%s\\*.*"), sc->path);
+
+ WIN32_FIND_DATA ffd = {0};
+ HANDLE hFFD = FindFirstFile(filename, &ffd);
+ if (hFFD != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ mir_sntprintf(filename, MAX_REGS(filename), _T("%s\\%s"), sc->path, ffd.cFileName);
+
+ if (!FileExists(filename))
+ continue;
- mir_snprintf(setting, MAX_REGS(setting), "%d_Path", c->lastId);
- DBWriteContactSettingString(c->hContact, "CustomSmileys", setting, ce->path);
+ int len = lstrlen(ffd.cFileName);
+ if (len < 5)
+ continue;
+ if (lstrcmp(&ffd.cFileName[len-4], _T(".jpg")) != 0
+ && lstrcmp(&ffd.cFileName[len-4], _T(".gif")) != 0
+ && lstrcmp(&ffd.cFileName[len-4], _T(".png")))
+ continue;
+
+ CreateCustomSmiley(c, filename);
+ }
+ while(FindNextFile(hFFD, &ffd));
+
+ FindClose(hFFD);
+ }
+ }
+ else if (sc->type == 1)
+ {
+ if (FileExists(sc->path))
+ CreateCustomSmiley(c, sc->path);
+ }
return 0;
}
diff --git a/Plugins/emoticons/options.cpp b/Plugins/emoticons/options.cpp index e3639e5..76b68a1 100644 --- a/Plugins/emoticons/options.cpp +++ b/Plugins/emoticons/options.cpp @@ -38,10 +38,11 @@ static OptPageControl optionsControls[] = { { &opts.replace_in_input, CONTROL_CHECKBOX, IDC_INPUT_TOO, "ReplaceInInput", TRUE },
{ &opts.use_default_pack, CONTROL_CHECKBOX, IDC_USE_DEFAULT_PACK, "UseDefaultPack", TRUE },
{ &opts.only_replace_isolated, CONTROL_CHECKBOX, IDC_ONLY_ISOLATED, "OnlyReplaceIsolatedEmoticons", FALSE },
+ { &opts.enable_custom_smileys, CONTROL_CHECKBOX, IDC_CUSTOM_SMILEYS, "EnableCustomSmileys", TRUE },
};
static UINT optionsExpertControls[] = {
- IDC_INPUT_TOO, IDC_USE_DEFAULT_PACK, IDC_ONLY_ISOLATED
+ IDC_INPUT_TOO, IDC_USE_DEFAULT_PACK, IDC_ONLY_ISOLATED, IDC_CUSTOM_SMILEYS
};
@@ -183,6 +184,12 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA DBWriteContactSettingString(NULL, MODULE_NAME, "DefaultPack", pack->name);
strcpy(opts.pack, pack->name);
FillModuleImages(pack);
+
+ BOOL ret = SaveOptsDlgProc(optionsControls, MAX_REGS(optionsControls), MODULE_NAME, hwndDlg, msg, wParam, lParam);
+
+ NotifyEventHooks(hChangedEvent, NULL, 0);
+
+ return ret;
}
break;
diff --git a/Plugins/emoticons/options.h b/Plugins/emoticons/options.h index 259c357..826e0f9 100644 --- a/Plugins/emoticons/options.h +++ b/Plugins/emoticons/options.h @@ -30,6 +30,7 @@ struct Options { BOOL replace_in_input;
BOOL use_default_pack;
BOOL only_replace_isolated;
+ BOOL enable_custom_smileys;
};
extern Options opts;
diff --git a/Plugins/emoticons/resource.h b/Plugins/emoticons/resource.h index 1f76c5e..8aea224 100644 --- a/Plugins/emoticons/resource.h +++ b/Plugins/emoticons/resource.h @@ -1,5 +1,5 @@ //{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
+// Microsoft Visual C++ generated include file.
// Used by resource.rc
//
#define IDD_OPTIONS 119
@@ -13,6 +13,8 @@ #define IDC_GETMORE 1076
#define IDC_EMOTICONS 1080
#define IDC_ONLY_ISOLATED 1086
+#define IDC_ONLY_ISOLATED2 1087
+#define IDC_CUSTOM_SMILEYS 1087
#define IDC_STATIC -1
// Next default values for new objects
diff --git a/Plugins/emoticons/resource.rc b/Plugins/emoticons/resource.rc index c508fef..cac5142 100644 --- a/Plugins/emoticons/resource.rc +++ b/Plugins/emoticons/resource.rc @@ -1,4 +1,4 @@ -//Microsoft Developer Studio generated resource script.
+// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
@@ -28,50 +28,42 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL //
IDD_OPTIONS_OLD DIALOGEX 0, 0, 252, 105
-STYLE DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX " Emoticons ",IDC_EMOTICONS,1,5,250,99
LTEXT "Pack:",IDC_STATIC,11,20,48,8
- COMBOBOX IDC_PACK,63,18,177,60,CBS_DROPDOWNLIST | WS_VSCROLL |
- WS_TABSTOP
+ COMBOBOX IDC_PACK,63,18,177,60,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Replace emoticons in text input area too",IDC_INPUT_TOO,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,40,230,10
- CONTROL "Use default emoticon pack for unknown protocols",
- IDC_USE_DEFAULT_PACK,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,10,52,230,10
- CONTROL "Ignore words in UPPER CASE",IDC_IGNORE_UPPERCASE,"Button",
- BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,10,64,230,
- 10
- CONTROL "Download more emoticon packs",IDC_GETMORE,"Hyperlink",
- WS_TABSTOP | 0x1,10,85,230,12
+ CONTROL "Use default emoticon pack for unknown protocols",IDC_USE_DEFAULT_PACK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,52,230,10
+ CONTROL "Ignore words in UPPER CASE",IDC_IGNORE_UPPERCASE,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,10,64,230,10
+ CONTROL "Download more emoticon packs",IDC_GETMORE,"Hyperlink",WS_TABSTOP | 0x1,10,85,230,12
END
IDD_EMOTICON_SELECTION DIALOGEX 0, 0, 188, 90
-STYLE WS_POPUP | WS_VISIBLE | WS_BORDER
+STYLE DS_SETFONT | WS_POPUP | WS_VISIBLE | WS_BORDER
EXSTYLE WS_EX_NOPARENTNOTIFY
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
END
-IDD_OPTIONS DIALOGEX 0, 0, 293, 228
-STYLE DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE
+IDD_OPTIONS DIALOGEX 0, 0, 293, 234
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
-FONT 8, "MS Shell Dlg"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LISTBOX IDC_PACK,7,2,277,148,LBS_OWNERDRAWVARIABLE |
- LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
+ LISTBOX IDC_PACK,7,2,277,148,LBS_OWNERDRAWVARIABLE | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
CONTROL "Replace emoticons in text input area too",IDC_INPUT_TOO,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,160,277,10
- CONTROL "Use default emoticon pack for unknown protocols",
- IDC_USE_DEFAULT_PACK,"Button",BS_AUTOCHECKBOX |
- WS_TABSTOP,7,172,277,10
- CONTROL "Only replace emoticons surrounded by spaces",
- IDC_ONLY_ISOLATED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 7,184,277,10
- CONTROL "Download more emoticon packs",IDC_GETMORE,"Hyperlink",
- WS_TABSTOP | 0x1,7,205,277,12
+ CONTROL "Use default emoticon pack for unknown protocols",IDC_USE_DEFAULT_PACK,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,172,277,10
+ CONTROL "Only replace emoticons surrounded by spaces",IDC_ONLY_ISOLATED,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,184,277,10
+ CONTROL "Download more emoticon packs",IDC_GETMORE,"Hyperlink",WS_TABSTOP | 0x1,7,218,277,12
+ CONTROL "Enable custom smileys",IDC_CUSTOM_SMILEYS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,196,277,10
END
@@ -81,7 +73,7 @@ END //
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
+GUIDELINES DESIGNINFO
BEGIN
IDD_OPTIONS_OLD, DIALOG
BEGIN
@@ -95,6 +87,7 @@ BEGIN BEGIN
LEFTMARGIN, 1
TOPMARGIN, 1
+ BOTTOMMARGIN, 228
END
END
#endif // APSTUDIO_INVOKED
@@ -118,19 +111,19 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN // TEXTINCLUDE
//
-1 TEXTINCLUDE DISCARDABLE
+1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
-2 TEXTINCLUDE DISCARDABLE
+2 TEXTINCLUDE
BEGIN
"#include ""resource.h""\r\n"
"#include ""winresrc.h""\r\n"
"\0"
END
-3 TEXTINCLUDE DISCARDABLE
+3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
diff --git a/Plugins/emoticons/sdk/m_customsmileys.h b/Plugins/emoticons/sdk/m_customsmileys.h deleted file mode 100644 index afe99bd..0000000 --- a/Plugins/emoticons/sdk/m_customsmileys.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef __M_CUSTOMSMILEYS_H__
-# define __M_CUSTOMSMILEYS_H__
-
-
-#define CUSTOMSMILEY_STATE_RECEIVED 1
-#define CUSTOMSMILEY_STATE_DOWNLOADED 2
-#define CUSTOMSMILEY_UNICODE 0x100
-
-#ifdef UNICODE
-# define CUSTOMSMILEY_TCHAR CUSTOMSMILEY_UNICODE
-#else
-# define CUSTOMSMILEY_TCHAR 0
-#endif
-
-typedef struct
-{
- int cbSize;
- HANDLE hContact;
- union {
- const char *pszText; // Valid only during the notification. Optional if CUSTOMSMILEY_STATE_DOWNLOADED
- const TCHAR *ptszText; // Valid only during the notification. Optional if CUSTOMSMILEY_STATE_DOWNLOADED
- const WCHAR *pwszText; // Valid only during the notification. Optional if CUSTOMSMILEY_STATE_DOWNLOADED
- };
- const char *pszFilename; // Valid only during the notification
- int flags; // One of CUSTOMSMILEY_STATE_*
- BOOL download; // "Return" value. Someone have to change it to TRUE for it to be downloaded
-} CUSTOMSMILEY;
-
-
-// Fired when a custom smiley is received from a contact.
-// This can is fired 2 times:
-// 1. When received the text, with flag CUSTOMSMILEY_STATE_RECEIVED. If someone hooks this message and
-// wants the custom smiley, it has to change the download field to TRUE
-// 2. If needed, when the image was downloaded, with flag CUSTOMSMILEY_STATE_DOWNLOADED
-// If the protocol receives the smiley text and image at the same time, it can fire it only once, with
-// flag (CUSTOMSMILEY_STATE_RECEIVED | CUSTOMSMILEY_STATE_DOWNLOADED)
-//
-// wParam = 0
-// lParam = CUSTOMSMILEY *
-#define ME_CUSTOMSMILEY_RECEIVED "/CustomSmileyReceived"
-
-
-
-
-
-
-
-
-
-
-
-#endif __M_CUSTOMSMILEYS_H__
diff --git a/Plugins/emoticons/sdk/m_smileyadd.h b/Plugins/emoticons/sdk/m_smileyadd.h index 18e2462..2de1b61 100644 --- a/Plugins/emoticons/sdk/m_smileyadd.h +++ b/Plugins/emoticons/sdk/m_smileyadd.h @@ -1,12 +1,12 @@ /*
Miranda SmileyAdd Plugin
-Plugin support header file
-Copyright (C) 2004-2007 Boris Krasnovskiy, portions by Rein-Peter de Boer
+Copyright (C) 2005-2008 Boris Krasnovskiy
+Copyright (C) 2003-2004 Rein-Peter de Boer
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.
+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
@@ -14,10 +14,9 @@ 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.
+along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+#include <richedit.h>
#define SAFLRE_INSERTEMF 2 // insert smiley as EMF into RichEdit, otherwise bitmap inserted
// this flag allows "true" transparency
@@ -180,3 +179,17 @@ typedef struct // {E03C71B2-6DEE-467e-A4F0-DD516745876A}
#define MIID_SMILEY { 0xe03c71b2, 0x6dee, 0x467e, { 0xa4, 0xf0, 0xdd, 0x51, 0x67, 0x45, 0x87, 0x6a } }
#endif
+
+
+typedef struct
+{
+ unsigned cbSize; // size of the structure
+ HANDLE hContact;
+ int type; // 0 - directory, 1 - file;
+ TCHAR* path; // smiley category name for reference
+} SMADD_CONT;
+
+//Loads all smileys for the contact
+//wParam = (WPARAM) 0; not used
+//lParam = (LPARAM) (SMADD_CONT*) &dir; // pointer to directory to load smiley from
+#define MS_SMILEYADD_LOADCONTACTSMILEYS "SmileyAdd/LoadContactSmileys"
|