diff options
Diffstat (limited to 'protocols/AimOscar/src/links.cpp')
-rw-r--r-- | protocols/AimOscar/src/links.cpp | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/protocols/AimOscar/src/links.cpp b/protocols/AimOscar/src/links.cpp index ee4709ac0c..ea187bfbe6 100644 --- a/protocols/AimOscar/src/links.cpp +++ b/protocols/AimOscar/src/links.cpp @@ -22,7 +22,6 @@ static HANDLE hServiceParseLink; extern OBJLIST<CAimProto> g_Instances;
-
static int SingleHexToDecimal(TCHAR c)
{
if (c >= '0' && c <= '9') return c - '0';
@@ -35,21 +34,17 @@ static TCHAR* url_decode(TCHAR* str) {
TCHAR* s = str, *d = str;
- while(*s)
- {
- if (*s == '%')
- {
+ while (*s) {
+ if (*s == '%') {
int digit1 = SingleHexToDecimal(s[1]);
- if (digit1 != -1)
- {
+ if (digit1 != -1) {
int digit2 = SingleHexToDecimal(s[2]);
- if (digit2 != -1)
- {
+ if (digit2 != -1) {
s += 3;
*d++ = (TCHAR)((digit1 << 4) | digit2);
continue;
- }
- }
+ }
+ }
}
*d++ = *s++;
}
@@ -58,7 +53,7 @@ static TCHAR* url_decode(TCHAR* str) return str;
}
-static INT_PTR ServiceParseAimLink(WPARAM,LPARAM lParam)
+static INT_PTR ServiceParseAimLink(WPARAM, LPARAM lParam)
{
if (lParam == 0) return 1; /* sanity check */
@@ -75,10 +70,8 @@ static INT_PTR ServiceParseAimLink(WPARAM,LPARAM lParam) if (g_Instances.getCount() == 0) return 0;
CAimProto *proto = &g_Instances[0];
- for (int i = 0; i < g_Instances.getCount(); ++i)
- {
- if (g_Instances[i].m_iStatus != ID_STATUS_OFFLINE && !IsStatusConnecting(g_Instances[i].m_iStatus))
- {
+ for (int i = 0; i < g_Instances.getCount(); ++i) {
+ if (g_Instances[i].m_iStatus != ID_STATUS_OFFLINE && !IsStatusConnecting(g_Instances[i].m_iStatus)) {
proto = &g_Instances[i];
break;
}
@@ -91,13 +84,11 @@ static INT_PTR ServiceParseAimLink(WPARAM,LPARAM lParam) open chatroom: aim:gochat?roomname=ROOM&exchange=NUM
*/
/* add a contact to the list */
- if (!_tcsnicmp(arg, _T("addbuddy?"), 9))
- {
- TCHAR *tok, *tok2;
+ if (!_tcsnicmp(arg, _T("addbuddy?"), 9)) {
+ TCHAR *tok, *tok2;
char *sn = NULL, *group = NULL;
-
- for (tok = arg + 8; tok != NULL; tok = tok2)
- {
+
+ for (tok = arg + 8; tok != NULL; tok = tok2) {
tok2 = _tcschr(++tok, '&'); /* first token */
if (tok2) *tok2 = 0;
if (!_tcsnicmp(tok, _T("screenname="), 11) && *(tok + 11) != 0)
@@ -105,8 +96,7 @@ static INT_PTR ServiceParseAimLink(WPARAM,LPARAM lParam) if (!_tcsnicmp(tok, _T("groupname="), 10) && *(tok + 10) != 0)
group = mir_utf8encodeT(url_decode(tok + 10)); /* group is currently ignored */
}
- if (sn == NULL)
- {
+ if (sn == NULL) {
mir_free(group);
return 1;
}
@@ -121,15 +111,13 @@ static INT_PTR ServiceParseAimLink(WPARAM,LPARAM lParam) return 0;
}
/* send a message to a contact */
- else if (!_tcsnicmp(arg, _T("goim?"), 5))
- {
+ else if (!_tcsnicmp(arg, _T("goim?"), 5)) {
TCHAR *tok, *tok2, *msg = NULL;
char *sn = NULL;
- for (tok = arg + 4; tok != NULL; tok = tok2)
- {
+ for (tok = arg + 4; tok != NULL; tok = tok2) {
tok2 = _tcschr(++tok, '&'); /* first token */
- if (tok2) *tok2=0;
+ if (tok2) *tok2 = 0;
if (!_tcsnicmp(tok, _T("screenname="), 11) && *(tok + 11) != 0)
sn = mir_t2a(url_decode(tok + 11));
if (!_tcsnicmp(tok, _T("message="), 8) && *(tok + 8) != 0)
@@ -144,35 +132,32 @@ static INT_PTR ServiceParseAimLink(WPARAM,LPARAM lParam) mir_free(sn);
return 0;
}
+
/* open a chatroom */
- else if (!_tcsnicmp(arg, _T("gochat?"), 7))
- {
+ else if (!_tcsnicmp(arg, _T("gochat?"), 7)) {
TCHAR *tok, *tok2;
char *rm = NULL;
int exchange = 0;
- for (tok = arg + 6; tok != NULL; tok = tok2)
- {
+ for (tok = arg + 6; tok != NULL; tok = tok2) {
tok2 = _tcschr(++tok, '&'); /* first token */
if (tok2) *tok2 = 0;
- if (!_tcsnicmp(tok, _T("roomname="), 9) && *(tok + 9) != 0)
- {
+ if (!_tcsnicmp(tok, _T("roomname="), 9) && *(tok + 9) != 0) {
rm = mir_t2a(url_decode(tok + 9));
for (char *ch = rm; *ch; ++ch)
if (*ch == '+') *ch = ' ';
}
if (!_tcsnicmp(tok, _T("exchange="), 9))
- exchange = _ttoi(tok + 9);
+ exchange = _ttoi(tok + 9);
}
- if (rm == NULL || exchange <= 0)
- {
+ if (rm == NULL || exchange <= 0) {
mir_free(rm);
return 1;
}
chatnav_param* par = new chatnav_param(rm, (unsigned short)exchange);
proto->ForkThread(&CAimProto::chatnav_request_thread, par);
-
+
mir_free(rm);
return 0;
}
|