summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2008-04-20 23:13:28 +0000
committerpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2008-04-20 23:13:28 +0000
commit97a1ad6aa3f9696313a6d1e2e073b1e08a6b5682 (patch)
tree3fa5c0c9e27a2abc9e0d8d07c7b7dffb07c31bb3
parentbc4d907594198a9c0de29e08916714f0d8eaea15 (diff)
Support for accounts and jabber transports
Fix for frame in selection window git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@88 c086bb3d-8645-0410-b8da-73a8550f86e7
-rw-r--r--Plugins/emoticons/Docs/emoticons_changelog.txt8
-rw-r--r--Plugins/emoticons/Docs/emoticons_version.txt2
-rw-r--r--Plugins/emoticons/EmoticonsSelectionLayout.h3
-rw-r--r--Plugins/emoticons/GroupListEmoticons.cpp52
-rw-r--r--Plugins/emoticons/SingleListEmoticons.cpp11
-rw-r--r--Plugins/emoticons/commons.h22
-rw-r--r--Plugins/emoticons/data/Plugins/Emoticons/Default.emo2
-rw-r--r--Plugins/emoticons/data/Plugins/Emoticons/JGMAIL.emo7
-rw-r--r--Plugins/emoticons/data/Plugins/Emoticons/Skype.emo2
-rw-r--r--Plugins/emoticons/emoticons.cpp207
-rw-r--r--Plugins/emoticons/options.cpp8
-rw-r--r--Plugins/emoticons/selwin.cpp14
12 files changed, 240 insertions, 98 deletions
diff --git a/Plugins/emoticons/Docs/emoticons_changelog.txt b/Plugins/emoticons/Docs/emoticons_changelog.txt
index 601a3b1..ad38926 100644
--- a/Plugins/emoticons/Docs/emoticons_changelog.txt
+++ b/Plugins/emoticons/Docs/emoticons_changelog.txt
@@ -2,6 +2,14 @@ Emoticons
Changelog:
+. 0.0.2.2
+ + Support for accounts and jabber transports
+ * Fix for frame in selection window
+
+. 0.0.2.1
+ * Fix for guessing fonts of Scriver
+ * Show less flags in options dialog
+
. 0.0.2.0
+ New selection window layout
+ Support for service calls in .emo
diff --git a/Plugins/emoticons/Docs/emoticons_version.txt b/Plugins/emoticons/Docs/emoticons_version.txt
index 390f6e8..3ed91f8 100644
--- a/Plugins/emoticons/Docs/emoticons_version.txt
+++ b/Plugins/emoticons/Docs/emoticons_version.txt
@@ -1 +1 @@
-Emoticons 0.0.2.0 \ No newline at end of file
+Emoticons 0.0.2.2 \ No newline at end of file
diff --git a/Plugins/emoticons/EmoticonsSelectionLayout.h b/Plugins/emoticons/EmoticonsSelectionLayout.h
index 6b13a5f..27920a9 100644
--- a/Plugins/emoticons/EmoticonsSelectionLayout.h
+++ b/Plugins/emoticons/EmoticonsSelectionLayout.h
@@ -1,5 +1,5 @@
#define MIN_COLS 6
-#define MAX_LINES 8
+#define MAX_LINES 6
#define MAX_COLS 12
#define BORDER 3
@@ -8,6 +8,7 @@ struct EmoticonSelectionData
{
HANDLE hContact;
Module *module;
+ const char *proto;
COLORREF background;
int xPosition;
diff --git a/Plugins/emoticons/GroupListEmoticons.cpp b/Plugins/emoticons/GroupListEmoticons.cpp
index cc9f3a2..1d45c2b 100644
--- a/Plugins/emoticons/GroupListEmoticons.cpp
+++ b/Plugins/emoticons/GroupListEmoticons.cpp
@@ -93,6 +93,9 @@ void GroupListEmoticons::Load()
{
Emoticon *e = ssd->module->emoticons[i];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
if (stricmp(e->group, current_group) != 0 || i == 0)
{
if (i != 0)
@@ -103,6 +106,11 @@ void GroupListEmoticons::Load()
SetGroupName(groups[current_id], current_group);
groups[current_id].start = i;
+ groups[current_id].count = 1;
+ }
+ else
+ {
+ groups[current_id].count++;
}
}
groups[current_id].end = i - 1;
@@ -112,7 +120,6 @@ void GroupListEmoticons::Load()
for(i = 0; i < num_groups; i++)
{
Group &group = groups[i];
- group.count = group.end - group.start + 1;
GetMaxEmoticonSize(group);
group.cols = GetNumOfCols(group.count);
@@ -160,6 +167,9 @@ int GroupListEmoticons::CountGroups()
{
Emoticon *e = ssd->module->emoticons[i];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
if (stricmp(e->group, current_group) != 0)
{
current_group = e->group;
@@ -187,6 +197,9 @@ void GroupListEmoticons::GetMaxEmoticonSize(Group &group)
{
Emoticon *e = ssd->module->emoticons[i];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
int height, width;
GetEmoticonSize(e, width, height);
@@ -198,7 +211,7 @@ void GroupListEmoticons::GetMaxEmoticonSize(Group &group)
RECT GroupListEmoticons::GetEmoticonRect(Group &group, int index)
{
- int pos = index - group.start;
+ int pos = index;
int line = pos / group.cols;
int col = pos % group.cols;
@@ -225,14 +238,19 @@ void GroupListEmoticons::CreateToolTips()
top += HeightWithBorders(rc);
}
+ int index = 0;
for (int j = group.start; j <= group.end; j++)
{
Emoticon *e = ssd->module->emoticons[j];
- RECT rc = GetEmoticonRect(group, j);
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
+ RECT rc = GetEmoticonRect(group, index);
rc.top += top;
rc.bottom += top;
CreateEmoticonToolTip(e, rc);
+ index++;
}
top += group.max_height * group.lines + (group.lines + 1) * BORDER;
@@ -246,7 +264,20 @@ int GroupListEmoticons::HeightWithBorders(RECT rc)
int GroupListEmoticons::GetIndex(Group &group, int line, int col)
{
- return line * group.cols + col + group.start;
+ int desired = line * group.cols + col;
+ int index = 0;
+ for (int j = group.start; j <= group.end; j++)
+ {
+ Emoticon *e = ssd->module->emoticons[j];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
+ if (index == desired)
+ return j;
+
+ index++;
+ }
+ return -1;
}
void GroupListEmoticons::SetSelection(HWND hwnd, POINT p)
@@ -284,7 +315,7 @@ void GroupListEmoticons::SetSelection(HWND hwnd, POINT p)
int index = GetIndex(group, line, col);
- if (col >= 0 && line >= 0 && index <= group.end)
+ if (col >= 0 && col < group.cols && line >= 0 && line < group.lines && index <= group.end)
{
EmoticonsSelectionLayout::SetSelection(hwnd, index);
}
@@ -462,13 +493,20 @@ void GroupListEmoticons::Draw(HDC hdc)
top += HeightWithBorders(rc);
}
+ int index = 0;
for (int j = group.start; j <= group.end; j++)
- {
- RECT rc = GetEmoticonRect(group, j);
+ {
+ Emoticon *e = ssd->module->emoticons[j];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
+ RECT rc = GetEmoticonRect(group, index);
rc.top += top;
rc.bottom += top;
DrawEmoticon(hdc, j, rc);
+
+ index++;
}
top += group.max_height * group.lines + (group.lines + 1) * BORDER;
diff --git a/Plugins/emoticons/SingleListEmoticons.cpp b/Plugins/emoticons/SingleListEmoticons.cpp
index 1015d33..68f3df1 100644
--- a/Plugins/emoticons/SingleListEmoticons.cpp
+++ b/Plugins/emoticons/SingleListEmoticons.cpp
@@ -22,6 +22,9 @@ void SingleListEmoticons::GetMaxEmoticonSize()
{
Emoticon *e = ssd->module->emoticons[i];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
int height, width;
GetEmoticonSize(e, width, height);
@@ -49,6 +52,10 @@ void SingleListEmoticons::CreateToolTips()
break;
Emoticon *e = ssd->module->emoticons[index];
+
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
CreateEmoticonToolTip(e, GetEmoticonRect(line, col));
}
}
@@ -193,6 +200,10 @@ void SingleListEmoticons::Draw(HDC hdc)
if (index >= emoticons.count)
break;
+ Emoticon *e = ssd->module->emoticons[index];
+ if (e->service[0] != NULL && !ProtoServiceExists(ssd->proto, e->service[0]))
+ continue;
+
DrawEmoticon(hdc, index, GetEmoticonRect(line, col));
}
}
diff --git a/Plugins/emoticons/commons.h b/Plugins/emoticons/commons.h
index ec632bc..32523bd 100644
--- a/Plugins/emoticons/commons.h
+++ b/Plugins/emoticons/commons.h
@@ -44,7 +44,7 @@ using namespace std;
// Miranda headers
-#define MIRANDA_VER 0x0700
+#define MIRANDA_VER 0x0800
#include <win2k.h>
#include <newpluginapi.h>
#include <m_system.h>
@@ -162,7 +162,13 @@ struct Module
TCHAR *path;
LIST<Emoticon> emoticons;
- Module() : name(0), path(0), emoticons(20) {}
+ struct {
+ char *proto_name;
+ char *db_key;
+ char *db_val;
+ } derived;
+
+ Module() : name(0), path(0), emoticons(20) { derived.proto_name=0; derived.db_key=0; derived.db_val=0; }
~Module();
};
@@ -225,7 +231,7 @@ extern TCHAR emoticonPacksFolder[1024];
HANDLE GetRealContact(HANDLE hContact);
-Module *GetModule(const char *name);
+Module * GetContactModule(HANDLE hContact, const char *proto = NULL);
void FillModuleImages(EmoticonPack *pack);
@@ -236,4 +242,14 @@ void FillModuleImages(EmoticonPack *pack);
#include "GroupListEmoticons.h"
+// See if a protocol service exists
+static __inline int ProtoServiceExists(const char *szModule,const char *szService)
+{
+ char str[MAXMODULELABELLENGTH];
+ strcpy(str,szModule);
+ strcat(str,szService);
+ return ServiceExists(str);
+}
+
+
#endif // __COMMONS_H__
diff --git a/Plugins/emoticons/data/Plugins/Emoticons/Default.emo b/Plugins/emoticons/data/Plugins/Emoticons/Default.emo
index bde2c21..a672adc 100644
--- a/Plugins/emoticons/data/Plugins/Emoticons/Default.emo
+++ b/Plugins/emoticons/data/Plugins/Emoticons/Default.emo
@@ -1,5 +1,7 @@
# Default emoticons
+[Default]
+
"smile" = "Smile", ":-)" ":)"
"laugh" = "Laught", ":-D" ":D"
"wink" = "Wink", ";-)" ";)"
diff --git a/Plugins/emoticons/data/Plugins/Emoticons/JGMAIL.emo b/Plugins/emoticons/data/Plugins/Emoticons/JGMAIL.emo
index 3f5099d..69250d0 100644
--- a/Plugins/emoticons/data/Plugins/Emoticons/JGMAIL.emo
+++ b/Plugins/emoticons/data/Plugins/Emoticons/JGMAIL.emo
@@ -1,5 +1,8 @@
# Google Talk protocol emoticons
+Derived: JABBER : ManualHost=atalk.google.com
+
+
[Google Talk]
"smile" = "Smile", ":)" ":-)" "=)"
@@ -28,7 +31,3 @@
"kiss" = "Kiss", ":*" ":-x"
"mustache" = "Mustache", ":{"
-
-[Nudge]
-
-"service_nudge" = "Nudge", "<Service:/SendNudge:hContact:0>"
diff --git a/Plugins/emoticons/data/Plugins/Emoticons/Skype.emo b/Plugins/emoticons/data/Plugins/Emoticons/Skype.emo
index e366f62..9e8361b 100644
--- a/Plugins/emoticons/data/Plugins/Emoticons/Skype.emo
+++ b/Plugins/emoticons/data/Plugins/Emoticons/Skype.emo
@@ -20,7 +20,7 @@
"mean" = "Evil grin", "]:)" ">:)" "(grin)"
"talking" = "Talking", "(talk)"
"yawn" = "Yawn", "(yawn)" "|-()"
-"sick" = "Puke", "(puke)" ":&amp;" ":-&amp;" ":=&amp;"
+"sick" = "Puke", "(puke)" ":&" ":-&" ":=&"
"doh" = "Doh!", "(doh)"
"angry" = "Angry", ":@" ":-@" ":=@" "x(" "x-(" "x=(" "X(" "X-(" "X=("
"eyeroll" = "It wasn't me", "(wasntme)"
diff --git a/Plugins/emoticons/emoticons.cpp b/Plugins/emoticons/emoticons.cpp
index 6d86839..5ec6769 100644
--- a/Plugins/emoticons/emoticons.cpp
+++ b/Plugins/emoticons/emoticons.cpp
@@ -30,7 +30,7 @@ PLUGININFOEX pluginInfo={
#else
"Emoticons",
#endif
- PLUGIN_MAKE_VERSION(0,0,2,0),
+ PLUGIN_MAKE_VERSION(0,0,2,2),
"Emoticons",
"Ricardo Pescuma Domenecci",
"",
@@ -91,7 +91,8 @@ void log(const char *fmt, ...);
void FillModuleImages(EmoticonPack *pack);
EmoticonPack *GetPack(char *name);
-Module *GetModule(const char *name);
+Module * GetContactModule(HANDLE hContact, const char *proto);
+Module * GetModule(const char *name);
Contact * GetContact(HANDLE hContact);
CustomEmoticon *GetCustomEmoticon(Contact *c, TCHAR *text);
EmoticonImage * GetModuleImage(EmoticonImage *img, Module *m);
@@ -227,20 +228,24 @@ extern "C" int __declspec(dllexport) Unload(void)
COLORREF GetSRMMColor(char *tabsrmm, char *scriver, COLORREF def)
{
- COLORREF colour = (COLORREF) DBGetContactSettingDword(NULL, "TabSRMM_Fonts", tabsrmm, -1); // TabSRMM
- if (colour == -1)
+ COLORREF colour = (COLORREF) -1;
+ if (ServiceExists("SRMsg_MOD/SetUserPrefs"))
+ colour = (COLORREF) DBGetContactSettingDword(NULL, "TabSRMM_Fonts", tabsrmm, -1); // TabSRMM
+ if (colour == (COLORREF) -1)
colour = (COLORREF) DBGetContactSettingDword(NULL, "SRMM", scriver, -1); // Scriver / SRMM
- if (colour == -1)
+ if (colour == (COLORREF) -1)
colour = def; // Default
return colour;
}
BYTE GetSRMMByte(char *tabsrmm, char *scriver, BYTE def)
{
- BYTE ret = (BYTE) DBGetContactSettingByte(NULL, "TabSRMM_Fonts", tabsrmm, -1); // TabSRMM
- if (ret == -1)
+ BYTE ret = (BYTE) -1;
+ if (ServiceExists("SRMsg_MOD/SetUserPrefs"))
+ ret = (BYTE) DBGetContactSettingByte(NULL, "TabSRMM_Fonts", tabsrmm, -1); // TabSRMM
+ if (ret == (BYTE) -1)
ret = (BYTE) DBGetContactSettingByte(NULL, "SRMM", scriver, -1); // Scriver / SRMM
- if (ret == -1)
+ if (ret == (BYTE) -1)
ret = def; // Default
return ret;
}
@@ -248,7 +253,7 @@ BYTE GetSRMMByte(char *tabsrmm, char *scriver, BYTE def)
void GetSRMMTString(TCHAR *out, size_t out_size, char *tabsrmm, char *scriver, TCHAR *def)
{
DBVARIANT dbv;
- if (!DBGetContactSettingTString(NULL, "TabSRMM_Fonts", tabsrmm, &dbv))
+ if (ServiceExists("SRMsg_MOD/SetUserPrefs") && !DBGetContactSettingTString(NULL, "TabSRMM_Fonts", tabsrmm, &dbv))
{
lstrcpyn(out, dbv.ptszVal, out_size);
DBFreeVariant(&dbv);
@@ -496,8 +501,6 @@ int ReplaceEmoticonBackwards(RichEditCtrl &rec, Contact *contact, Module *module
for(int i = 0; i < module->emoticons.getCount(); i++)
{
Emoticon *e = module->emoticons[i];
-// if (e->img == NULL)
-// continue;
for(int j = 0; j < e->texts.getCount(); j++)
{
@@ -1207,13 +1210,7 @@ int MsgWindowEvent(WPARAM wParam, LPARAM lParam)
if (event->uType == MSG_WINDOW_EVT_OPEN)
{
- HANDLE hReal = GetRealContact(event->hContact);
-
- char *proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hReal, 0);
- if (proto == NULL)
- return 0;
-
- Module *m = GetModule(proto);
+ Module *m = GetContactModule(event->hContact);
if (m == NULL)
return 0;
@@ -1311,17 +1308,19 @@ BOOL HasProto(char *proto)
{
PROTOCOLDESCRIPTOR **protos;
int count;
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos);
+ CallService(MS_PROTO_ENUMPROTOS, (WPARAM)&count, (LPARAM)&protos);
for (int i = 0; i < count; i++)
{
- if (protos[i]->type != PROTOTYPE_PROTOCOL)
+ PROTOCOLDESCRIPTOR *p = protos[i];
+
+ if (p->type != PROTOTYPE_PROTOCOL)
continue;
- if (protos[i]->szName == NULL || protos[i]->szName[0] == '\0')
+ if (p->szName == NULL || p->szName[0] == '\0')
continue;
- if (stricmp(proto, protos[i]->szName) == 0)
+ if (stricmp(proto, p->szName) == 0)
return TRUE;
}
@@ -1349,12 +1348,6 @@ void LoadModules()
char *name = mir_t2a(ffd.cFileName);
name[strlen(name) - 4] = 0;
- if (stricmp("Default", name) != 0 && !HasProto(name))
- {
- mir_free(name);
- continue;
- }
-
Module *m = new Module();
m->name = name;
m->path = mir_tstrdup(file);
@@ -1369,16 +1362,6 @@ void LoadModules()
}
-// See if a protocol service exists
-__inline int ProtoServiceExists(const char *szModule,const char *szService)
-{
- char str[MAXMODULELABELLENGTH];
- strcpy(str,szModule);
- strcat(str,szService);
- return ServiceExists(str);
-}
-
-
void HandleEmoLine(Module *m, char *tmp, char *group)
{
int len = strlen(tmp);
@@ -1470,12 +1453,12 @@ void HandleEmoLine(Module *m, char *tmp, char *group)
params = pos + 1;
}
- if (e->service[0] == NULL || e->service[0][0] == '\0' || !ProtoServiceExists(m->name, e->service[0]))
- {
- delete e;
- e = NULL;
- return;
- }
+// if (e->service[0] == NULL || e->service[0][0] == '\0' || !ProtoServiceExists(m->name, e->service[0]))
+// {
+// delete e;
+// e = NULL;
+// return;
+// }
}
else
e->texts.insert(txt);
@@ -1493,6 +1476,46 @@ void HandleEmoLine(Module *m, char *tmp, char *group)
}
+void HandleDerived(Module *m, char *derived)
+{
+ char *db_key = strchr(derived, ':');
+ if (db_key == NULL)
+ {
+ log("Invalid derived line '%s' in module %s", derived, m->name);
+ return;
+ }
+
+ *db_key = '\0';
+ db_key++;
+
+ char *db_val = strchr(db_key, '=');
+ if (db_val == NULL)
+ {
+ log("Invalid db string '%s' in derived line in module %s", db_key, m->name);
+ return;
+ }
+
+ *db_val = '\0';
+ db_val++;
+
+ if (db_val[0] != 'a')
+ {
+ log("Invalid db val '%s' (should start with a for ASCII) in derived line in module %s", db_val, m->name);
+ return;
+ }
+
+ db_val++;
+
+ strtrim(derived);
+ strtrim(db_key);
+ strtrim(db_val);
+
+ m->derived.proto_name = mir_strdup(derived);
+ m->derived.db_key = mir_strdup(db_key);
+ m->derived.db_val = mir_strdup(db_val);
+}
+
+
BOOL LoadModule(Module *m)
{
FILE *file = _tfopen(m->path, _T("rb"));
@@ -1523,6 +1546,10 @@ BOOL LoadModule(Module *m)
strtrim(&tmp[1]);
group = mir_strdup(&tmp[1]);
}
+ else if (strnicmp("Derived:", tmp, 8) == 0)
+ {
+ HandleDerived(m, &tmp[8]);
+ }
else
{
HandleEmoLine(m, tmp, group);
@@ -2004,6 +2031,70 @@ Module *GetModuleByName(const char *name)
}
+Module * GetContactModule(HANDLE hContact, const char *proto)
+{
+ if (hContact == NULL)
+ {
+ if (proto == NULL)
+ return NULL;
+ return GetModule(proto);
+ }
+
+ hContact = GetRealContact(hContact);
+
+ proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
+ if (proto == NULL)
+ return NULL;
+
+ PROTOACCOUNT *acc = ProtoGetAccount(proto);
+ if (acc == NULL)
+ return NULL;
+
+ proto = acc->szProtoName;
+
+ // Check for transports
+ if (stricmp("JABBER", proto) == 0)
+ {
+ DBVARIANT dbv = {0};
+ if (DBGetContactSettingString(hContact, acc->szModuleName, "Transport", &dbv) == 0)
+ {
+ Module *ret = GetModule(dbv.pszVal);
+
+ DBFreeVariant(&dbv);
+
+ return ret;
+ }
+ }
+
+ // Check if there is some derivation
+ for(int i = 0; i < modules.getCount(); i++)
+ {
+ Module *m = modules[i];
+
+ if (m->derived.proto_name == NULL)
+ continue;
+
+ if (stricmp(m->derived.proto_name, proto) != 0)
+ continue;
+
+ DBVARIANT dbv = {0};
+ if (DBGetContactSettingString(NULL, acc->szModuleName, m->derived.db_key, &dbv) != 0)
+ continue;
+
+ Module *ret = NULL;
+ if (stricmp(dbv.pszVal, m->derived.db_val) == 0)
+ ret = m;
+
+ DBFreeVariant(&dbv);
+
+ if (ret != NULL)
+ return ret;
+ }
+
+ return GetModule(proto);
+}
+
+
Module *GetModule(const char *name)
{
Module *ret = GetModuleByName(name);
@@ -2032,18 +2123,7 @@ int ReplaceEmoticonsService(WPARAM wParam, LPARAM lParam)
}
else
{
- const char *proto = NULL;
- if (sre->hContact != NULL)
- {
- HANDLE hReal = GetRealContact(sre->hContact);
- proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hReal, 0);
- }
- if (proto == NULL)
- proto = sre->Protocolname;
- if (proto == NULL)
- return FALSE;
-
- Module *m = GetModule(proto);
+ Module *m = GetContactModule(sre->hContact, sre->Protocolname);
if (m == NULL)
return FALSE;
@@ -2063,18 +2143,7 @@ int GetInfo2Service(WPARAM wParam, LPARAM lParam)
if (si == NULL || si->cbSize < sizeof(SMADD_INFO2))
return FALSE;
- const char *proto = NULL;
- if (si->hContact != NULL)
- {
- HANDLE hReal = GetRealContact(si->hContact);
- proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hReal, 0);
- }
- if (proto == NULL)
- proto = si->Protocolname;
- if (proto == NULL)
- return FALSE;
-
- Module *m = GetModule(proto);
+ Module *m = GetContactModule(si->hContact, si->Protocolname);
if (m == NULL)
return FALSE;
@@ -2561,6 +2630,8 @@ Contact * GetContact(HANDLE hContact)
{
if (hContact == NULL)
return NULL;
+
+ hContact = GetRealContact(hContact);
// Check if already loaded
for(int i = 0; i < contacts.getCount(); i++)
diff --git a/Plugins/emoticons/options.cpp b/Plugins/emoticons/options.cpp
index 7f1b513..13a02a4 100644
--- a/Plugins/emoticons/options.cpp
+++ b/Plugins/emoticons/options.cpp
@@ -130,11 +130,15 @@ static BOOL CALLBACK OptionsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
pd->max_height = 0;
pd->max_width = 0;
srand((unsigned int) time(NULL));
- int prob = (pd->pack->images.getCount() - 15) / 30 + 1;
+ int prob = (pd->pack->images.getCount() - 15) / 10 + 1;
for(int j = 0, count = 0; j < pd->pack->images.getCount() && count < 15; j++) {
if (rand() % prob != 0)
continue;
- pd->pack->images[j]->Load(pd->max_height, pd->max_width);
+ EmoticonImage *img = pd->pack->images[j];
+ if (strncmp(img->name, "flag_", 5) == 0)
+ if (rand() % 10 != 0)
+ continue;
+ img->Load(pd->max_height, pd->max_width);
count++;
}
diff --git a/Plugins/emoticons/selwin.cpp b/Plugins/emoticons/selwin.cpp
index 8cf15d0..d0f7301 100644
--- a/Plugins/emoticons/selwin.cpp
+++ b/Plugins/emoticons/selwin.cpp
@@ -330,16 +330,7 @@ int ShowSelectionService(WPARAM wParam, LPARAM lParam)
if (sss == NULL || sss->cbSize < sizeof(SMADD_SHOWSEL3))
return FALSE;
- const char *proto = NULL;
- HANDLE hContact = GetRealContact(sss->hContact);
- if (hContact != NULL)
- proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (proto == NULL)
- proto = sss->Protocolname;
- if (proto == NULL)
- return FALSE;
-
- Module *m = GetModule(proto);
+ Module *m = GetContactModule(sss->hContact, sss->Protocolname);
if (m == NULL)
return FALSE;
else if (m->emoticons.getCount() <= 0)
@@ -347,7 +338,8 @@ int ShowSelectionService(WPARAM wParam, LPARAM lParam)
EmoticonSelectionData * ssd = new EmoticonSelectionData();
ssd->module = m;
- ssd->hContact = hContact;
+ ssd->hContact = GetRealContact(sss->hContact);
+ ssd->proto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) ssd->hContact, 0);
ssd->xPosition = sss->xPosition;
ssd->yPosition = sss->yPosition;