summaryrefslogtreecommitdiff
path: root/Plugins
diff options
context:
space:
mode:
authorpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2008-04-30 02:29:58 +0000
committerpescuma <pescuma@c086bb3d-8645-0410-b8da-73a8550f86e7>2008-04-30 02:29:58 +0000
commitcb71ef0c3df96b6e28e3c8d293257bbb46287bbf (patch)
tree3938e989d4c6210050bc5a4fe39bd8d000cf0af8 /Plugins
parent56f7b0ebc97f8a8e6d7f7e875e93d18722a0e401 (diff)
Fix for jabber transports
git-svn-id: http://pescuma.googlecode.com/svn/trunk/Miranda@92 c086bb3d-8645-0410-b8da-73a8550f86e7
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/emoticons/Docs/emoticons_changelog.txt3
-rw-r--r--Plugins/emoticons/Docs/emoticons_version.txt2
-rw-r--r--Plugins/emoticons/emoticons.cpp137
3 files changed, 133 insertions, 9 deletions
diff --git a/Plugins/emoticons/Docs/emoticons_changelog.txt b/Plugins/emoticons/Docs/emoticons_changelog.txt
index 9c664de..e5ea839 100644
--- a/Plugins/emoticons/Docs/emoticons_changelog.txt
+++ b/Plugins/emoticons/Docs/emoticons_changelog.txt
@@ -2,6 +2,9 @@ Emoticons
Changelog:
+. 0.0.2.6
+ * Fix for jabber transports
+
. 0.0.2.5
+ Support for SRMM (but no button)
diff --git a/Plugins/emoticons/Docs/emoticons_version.txt b/Plugins/emoticons/Docs/emoticons_version.txt
index 4ea8b7c..5f5d1f4 100644
--- a/Plugins/emoticons/Docs/emoticons_version.txt
+++ b/Plugins/emoticons/Docs/emoticons_version.txt
@@ -1 +1 @@
-Emoticons 0.0.2.5 \ No newline at end of file
+Emoticons 0.0.2.6 \ No newline at end of file
diff --git a/Plugins/emoticons/emoticons.cpp b/Plugins/emoticons/emoticons.cpp
index e754b0c..4d4358c 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,5),
+ PLUGIN_MAKE_VERSION(0,0,2,6),
"Emoticons",
"Ricardo Pescuma Domenecci",
"",
@@ -2019,6 +2019,131 @@ const char * GetProtoID(const char *proto)
}
+/*
+Code block copied from Jabber sources (with small modifications)
+
+Copyright ( C ) 2002-04 Santithorn Bunchua
+Copyright ( C ) 2005-08 George Hazan
+
+Idea & portions of code by Artem Shpynov
+*/
+struct
+{
+ TCHAR *mask;
+ const char *proto;
+}
+static TransportProtoTable[] =
+{
+ { _T("|icq*|jit*"), "ICQ"},
+ { _T("msn*"), "MSN"},
+ { _T("yahoo*"), "YAHOO"},
+ { _T("mrim*"), "MRA"},
+ { _T("aim*"), "AIM"},
+ //request #3094
+ { _T("|gg*|gadu*"), "GaduGadu"},
+ { _T("tv*"), "TV"},
+ { _T("dict*"), "Dictionary"},
+ { _T("weather*"), "Weather"},
+ { _T("sms*"), "SMS"},
+ { _T("smtp*"), "SMTP"},
+ //j2j
+ { _T("gtalk.*.*"), "JGMAIL"},
+ { _T("xmpp.*.*"), "Jabber"},
+ //jabbim.cz - services
+ { _T("disk*"), "Jabber Disk"},
+ { _T("irc*"), "IRC"},
+ { _T("rss*"), "RSS"},
+ { _T("tlen*"), "Tlen"}
+};
+
+
+static inline TCHAR qtoupper( TCHAR c )
+{
+ return ( c >= 'a' && c <= 'z' ) ? c - 'a' + 'A' : c;
+}
+
+static BOOL WildComparei( const TCHAR* name, const TCHAR* mask )
+{
+ const TCHAR* last='\0';
+ for ( ;; mask++, name++) {
+ if ( *mask != '?' && qtoupper( *mask ) != qtoupper( *name ))
+ break;
+ if ( *name == '\0' )
+ return ((BOOL)!*mask);
+ }
+
+ if ( *mask != '*' )
+ return FALSE;
+
+ for (;; mask++, name++ ) {
+ while( *mask == '*' ) {
+ last = mask++;
+ if ( *mask == '\0' )
+ return ((BOOL)!*mask); /* true */
+ }
+
+ if ( *name == '\0' )
+ return ((BOOL)!*mask); /* *mask == EOS */
+ if ( *mask != '?' && qtoupper( *mask ) != qtoupper( *name ))
+ name -= (size_t)(mask - last) - 1, mask = last;
+} }
+
+#define NEWTSTR_ALLOCA(A) (A==NULL)?NULL:_tcscpy((TCHAR*)alloca(sizeof(TCHAR)*(_tcslen(A)+1)),A)
+
+static BOOL MatchMask( const TCHAR* name, const TCHAR* mask)
+{
+ if ( !mask || !name )
+ return mask == name;
+
+ if ( *mask != '|' )
+ return WildComparei( name, mask );
+
+ TCHAR* temp = NEWTSTR_ALLOCA(mask);
+ for ( int e=1; mask[e] != '\0'; e++ ) {
+ int s = e;
+ while ( mask[e] != '\0' && mask[e] != '|')
+ e++;
+
+ temp[e]= _T('\0');
+ if ( WildComparei( name, temp+s ))
+ return TRUE;
+
+ if ( mask[e] == 0 )
+ return FALSE;
+ }
+
+ return FALSE;
+}
+/*
+End of code block copied from Jabber sources
+*/
+
+const char *GetTransport(HANDLE hContact, const char *proto)
+{
+ if (!DBGetContactSettingByte(hContact, proto, "IsTransported", 0))
+ return NULL;
+
+ DBVARIANT dbv = {0};
+ if (DBGetContactSettingTString(hContact, proto, "Transport", &dbv) != 0)
+ return NULL;
+
+ const TCHAR *domain = dbv.ptszVal;
+ const char *transport = NULL;
+
+ for (int i = 0 ; i < MAX_REGS(TransportProtoTable); i++)
+ {
+ if (MatchMask(domain, TransportProtoTable[i].mask))
+ {
+ transport = TransportProtoTable[i].proto;
+ break;
+ }
+ }
+
+ DBFreeVariant(&dbv);
+ return transport;
+}
+
+
Module * GetContactModule(HANDLE hContact, const char *proto)
{
if (hContact == NULL)
@@ -2039,14 +2164,10 @@ Module * GetContactModule(HANDLE hContact, const char *proto)
// Check for transports
if (stricmp("JABBER", protoID) == 0)
{
- DBVARIANT dbv = {0};
- if (DBGetContactSettingString(hContact, proto, "Transport", &dbv) == 0)
+ const char *transport = GetTransport(hContact, proto);
+ if (transport != NULL)
{
- Module *ret = GetModule(dbv.pszVal);
-
- DBFreeVariant(&dbv);
-
- return ret;
+ return GetModule(transport);
}
}