summaryrefslogtreecommitdiff
path: root/protocols/Yahoo
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-27 08:05:12 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-27 08:05:12 +0000
commit248b320bc7e6ce0cfd6621d47a95b55e2264dd23 (patch)
tree5735f77b447dc0c1f41b9f1960dd4751cc6a0f83 /protocols/Yahoo
parent939b54967dcda681318271d203eedd1dcf5ce934 (diff)
sync
git-svn-id: http://svn.miranda-ng.org/main/trunk@646 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Yahoo')
-rw-r--r--protocols/Yahoo/Yahoo.rc231
-rw-r--r--protocols/Yahoo/chat.cpp617
-rw-r--r--protocols/Yahoo/proto.cpp11
-rw-r--r--protocols/Yahoo/proto.h52
-rw-r--r--protocols/Yahoo/resource.h14
-rw-r--r--protocols/Yahoo/server.cpp15
-rw-r--r--protocols/Yahoo/services.cpp22
-rw-r--r--protocols/Yahoo/user_info.cpp15
-rw-r--r--protocols/Yahoo/util.cpp10
-rw-r--r--protocols/Yahoo/yahoo.cpp14
10 files changed, 850 insertions, 151 deletions
diff --git a/protocols/Yahoo/Yahoo.rc b/protocols/Yahoo/Yahoo.rc
index 88956e6dfc..106dde33a1 100644
--- a/protocols/Yahoo/Yahoo.rc
+++ b/protocols/Yahoo/Yahoo.rc
@@ -1,18 +1,13 @@
-/*
- * $Id: Yahoo.rc 11954 2010-06-09 12:28:38Z borkra $
- *
- * myYahoo Miranda Plugin
- *
- * Authors: Gennady Feldman (aka Gena01)
- * Laurent Marechal (aka Peorth)
- *
- * This code is under GPL and is based on AIM, MSN and Miranda source code.
- * I want to thank Robert Rainwater and George Hazan for their code and support
- * and for answering some of my questions during development of this plugin.
- */
-#include <winresrc.h>
-
+// Microsoft Visual C++ generated resource script.
+//
+#include "winres.h"
#include "resource.h"
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
/////////////////////////////////////////////////////////////////////////////
//
@@ -24,38 +19,23 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- // Yahoo Login Information [Top Box]
GROUPBOX "Yahoo",IDC_STYAHOOGROUP,8,10,280,72
RTEXT "ID:",IDC_STATIC,16,20,52,8
EDITTEXT IDC_HANDLE,72,18,100,12,ES_AUTOHSCROLL
RTEXT "Password:",IDC_STATIC,16,36,52,8
EDITTEXT IDC_PASSWORD,72,34,100,12,ES_PASSWORD | ES_AUTOHSCROLL
- RTEXT "Nick:",IDC_STATIC,16,52,52,8
+ RTEXT "Nick:",IDC_STATIC,16,52,52,8
EDITTEXT IDC_NICK,72,50,100,12,ES_AUTOHSCROLL
- CONTROL "Create a new Yahoo account using the Yahoo website",
- IDC_NEWYAHOOACCOUNTLINK,"Hyperlink",WS_TABSTOP,21,66,208,8
-
- // Expert Section [Server/Port/etc]
+ CONTROL "Create a new Yahoo account using the Yahoo website",IDC_NEWYAHOOACCOUNTLINK,
+ "Hyperlink",WS_TABSTOP,21,66,208,8
GROUPBOX "Expert",IDC_STATIC,8,84,280,80
-
- /*CONTROL "Disable UTF8 encoding",IDC_DISABLE_UTF8,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,94,260,10
- */
- CONTROL "Use Yahoo Address Book (YAB)",IDC_USE_YAB,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,104,260,10
-
- CONTROL "Show Avatars",IDC_SHOW_AVATARS,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,114,260,10
-
- CONTROL "AutoLogin to Yahoo Website(s)",IDC_MAIL_AUTOLOGIN,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,124,260,10
-
- CONTROL "Display Yahoo notifications", IDC_DISABLEYAHOOMAIL,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,134,260,10
-
- CONTROL "Show Errors",IDC_SHOW_ERRORS,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,144,260,10
-
+ CONTROL "Use Yahoo Address Book (YAB)",IDC_USE_YAB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,104,260,10
+ CONTROL "Show Avatars",IDC_SHOW_AVATARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,114,260,10
+ CONTROL "AutoLogin to Yahoo Website(s)",IDC_MAIL_AUTOLOGIN,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,124,260,10
+ CONTROL "Display Yahoo notifications",IDC_DISABLEYAHOOMAIL,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,134,260,10
+ CONTROL "Show Errors",IDC_SHOW_ERRORS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,144,260,10
END
IDD_YAHOOACCOUNT DIALOGEX 0, 0, 186, 134
@@ -67,10 +47,7 @@ BEGIN
EDITTEXT IDC_HANDLE,54,0,131,12,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,0,16,53,12
EDITTEXT IDC_PASSWORD,54,16,131,12,ES_PASSWORD | ES_AUTOHSCROLL
-
- CONTROL "Yahoo Japan",IDC_YAHOO_JAPAN,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,0,32,140,12
-
+ CONTROL "Yahoo Japan",IDC_YAHOO_JAPAN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,0,32,140,12
CONTROL "Create a new Yahoo account",IDC_NEWYAHOOACCOUNTLINK,
"Hyperlink",WS_TABSTOP,0,48,174,12
END
@@ -80,18 +57,13 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
-
- // Expert Section [Server/Port/etc]
GROUPBOX "Connection Settings",IDC_STATIC,8,10,280,72
-
LTEXT "Login server:",IDC_STATIC,16,26,52,10
EDITTEXT IDC_LOGINSERVER,68,24,168,12,ES_AUTOHSCROLL
LTEXT "Port:",IDC_STATIC,16,42,25,10
EDITTEXT IDC_YAHOOPORT,68,40,29,12,ES_AUTOHSCROLL | ES_NUMBER
- PUSHBUTTON "Reset",IDC_RESETSERVER,244,24,40,12
-
- CONTROL "Yahoo Japan",IDC_YAHOO_JAPAN,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,16,58,140,10
+ PUSHBUTTON "Reset",IDC_RESETSERVER,244,24,40,12
+ CONTROL "Yahoo Japan",IDC_YAHOO_JAPAN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,58,140,10
END
IDD_OPT_YAHOO_IGNORE DIALOGEX 0, 0, 296, 220
@@ -100,32 +72,22 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
GROUPBOX "Yahoo Ignore List",IDC_STIGNGROUP,8,10,280,210
-
CONTROL "Ignore anyone who is not on my Yahoo buddy list ",IDC_OPT_IGN_UNKNOWN,
"Button",BS_AUTORADIOBUTTON,16,20,232,10
-
- CONTROL "Ignore only the people below: ",IDC_OPT_IGN_LIST,
- "Button",BS_AUTORADIOBUTTON,16,36,232,10
-
- EDITTEXT IDC_YIGN_EDIT,16,53,232,13,ES_AUTOHSCROLL
- PUSHBUTTON "&Add",IDC_IGN_ADD,250,52,34,12
-
- LISTBOX IDC_YIGN_LIST,16,68,232,150, LBS_NOTIFY | LBS_HASSTRINGS | LBS_SORT | WS_BORDER | WS_VSCROLL
-
- PUSHBUTTON "&Remove", IDC_IGN_REMOVE, 250,202,34,12
-
+ CONTROL "Ignore only the people below: ",IDC_OPT_IGN_LIST,"Button",BS_AUTORADIOBUTTON,16,36,232,10
+ EDITTEXT IDC_YIGN_EDIT,16,53,232,13,ES_AUTOHSCROLL
+ PUSHBUTTON "&Add",IDC_IGN_ADD,250,52,34,12
+ LISTBOX IDC_YIGN_LIST,16,68,232,150,LBS_SORT | LBS_HASSTRINGS | WS_VSCROLL
+ PUSHBUTTON "&Remove",IDC_IGN_REMOVE,250,202,34,12
END
-
IDD_SETCUSTSTAT DIALOGEX 0, 0, 187, 51
-STYLE DS_SETFONT | DS_FIXEDSYS | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Set Custom Status"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
EDITTEXT IDC_CUSTSTAT,5,5,177,12,ES_AUTOHSCROLL
- CONTROL "Show as busy",
- IDC_CUSTSTATBUSY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 5,21,120,10
+ CONTROL "Show as busy",IDC_CUSTSTATBUSY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,5,21,120,10
DEFPUSHBUTTON "OK",IDOK,36,34,50,14
PUSHBUTTON "Cancel",IDCANCEL,102,34,50,14
END
@@ -136,10 +98,9 @@ EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LTEXT "ID:",IDC_STATIC,0,1,97,8
- EDITTEXT IDC_SEARCH_ID,0,10,105,15,ES_AUTOHSCROLL
-
+ EDITTEXT IDC_SEARCH_ID,0,10,105,15,ES_AUTOHSCROLL
LTEXT "Protocol:",IDC_STATIC,0,31,97,38
- COMBOBOX IDC_SEARCH_PROTOCOL,0,40,105,75,CBS_DROPDOWNLIST
+ COMBOBOX IDC_SEARCH_PROTOCOL,0,40,105,75,CBS_DROPDOWNLIST
END
IDD_USER_INFO DIALOGEX 0, 0, 221, 132
@@ -147,19 +108,45 @@ STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- LTEXT "ID:", IDC_STATIC, 5, 5, 71,8
- EDITTEXT IDC_SEARCH_ID, 74, 5, 143, 12, ES_AUTOHSCROLL | ES_READONLY | NOT
- WS_BORDER
-
- LTEXT "Protocol:", IDC_STATIC, 5, 18, 71, 8
- EDITTEXT IDC_SEARCH_PROTOCOL, 74, 18, 143,12, ES_AUTOHSCROLL | ES_READONLY | NOT
- WS_BORDER
-
- LTEXT "Client:", IDC_STATIC, 5, 31, 71, 8
- EDITTEXT IDC_NFO_CLIENT, 74, 31, 143,12, ES_AUTOHSCROLL | ES_READONLY | NOT
- WS_BORDER
-
-
+ LTEXT "ID:",IDC_STATIC,5,5,71,8
+ EDITTEXT IDC_SEARCH_ID,74,5,143,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ LTEXT "Protocol:",IDC_STATIC,5,18,71,8
+ EDITTEXT IDC_SEARCH_PROTOCOL,74,18,143,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+ LTEXT "Client:",IDC_STATIC,5,31,71,8
+ EDITTEXT IDC_NFO_CLIENT,74,31,143,12,ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER
+END
+
+IDD_CHATROOM_INVITE_REQ DIALOGEX 0, 0, 177, 147
+STYLE DS_SETFONT | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
+EXSTYLE WS_EX_TOPMOST | WS_EX_WINDOWEDGE
+CAPTION "Chat Room Invitation Request"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ DEFPUSHBUTTON "&Join",IDOK,77,128,46,14
+ PUSHBUTTON "&Deny",IDCANCEL,125,128,45,14
+ LTEXT "Denial Message",IDC_STATIC,7,73,162,9
+ EDITTEXT IDC_MSG2,5,83,166,40,ES_MULTILINE | ES_AUTOHSCROLL | WS_VSCROLL | WS_HSCROLL
+ LTEXT "Invitation Message",IDC_STATIC,6,21,165,9
+ EDITTEXT IDC_MSG,6,31,166,40,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | WS_HSCROLL
+ LTEXT "Host",IDC_STATIC,5,7,73,8
+ CTEXT "",IDC_SCREENNAME,80,5,93,12,SS_SUNKEN
+END
+
+IDD_CHATROOM_INVITE DIALOGEX 0, 0, 302, 125
+STYLE DS_SETFONT | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_TOPMOST
+CAPTION "Invite Buddy To Chat Room"
+FONT 8, "MS Shell Dlg", 0, 0, 0x0
+BEGIN
+ LTEXT "Screen Name",IDC_STATIC,154,31,43,9
+ PUSHBUTTON "&Invite",IDOK,165,107,46,14
+ PUSHBUTTON "&Cancel",IDCANCEL,234,107,45,14
+ LTEXT "Invitation reason",IDC_STATIC,155,58,60,9
+ EDITTEXT IDC_MSG,154,68,140,32,ES_MULTILINE | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL
+ CONTROL "",IDC_CCLIST,"CListControl",WS_TABSTOP | 0x16f,7,4,141,117,WS_EX_CLIENTEDGE
+ EDITTEXT IDC_EDITSCR,154,41,93,12,ES_AUTOHSCROLL
+ PUSHBUTTON "Add",IDC_ADDSCR,247,40,49,14
+ CTEXT "",IDC_ROOMNAME,154,10,140,11,0,WS_EX_STATICEDGE
END
@@ -170,13 +157,73 @@ END
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
-IDI_YAHOO ICON "icos/yahoo.ico"
-IDI_INBOX ICON "icos/inbox.ico"
-IDI_PROFILE ICON "icos/profile.ico"
-IDI_REFRESH ICON "icos/refresh.ico"
-IDI_YAB ICON "icos/address_book.ico"
-IDI_SET_STATUS ICON "icos/set_status.ico"
-IDI_CALENDAR ICON "icos/calendar.ico"
-
-#include "version.rc"
+IDI_YAHOO ICON "icos/yahoo.ico"
+IDI_INBOX ICON "icos/inbox.ico"
+IDI_PROFILE ICON "icos/profile.ico"
+IDI_REFRESH ICON "icos/refresh.ico"
+IDI_YAB ICON "icos/address_book.ico"
+IDI_SET_STATUS ICON "icos/set_status.ico"
+IDI_CALENDAR ICON "icos/calendar.ico"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO
+BEGIN
+ IDD_CHATROOM_INVITE_REQ, DIALOG
+ BEGIN
+ BOTTOMMARGIN, 142
+ END
+
+ IDD_CHATROOM_INVITE, DIALOG
+ BEGIN
+ RIGHTMARGIN, 300
+ TOPMARGIN, 4
+ BOTTOMMARGIN, 121
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+#endif // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/protocols/Yahoo/chat.cpp b/protocols/Yahoo/chat.cpp
index c60a0cec8c..9275d90e86 100644
--- a/protocols/Yahoo/chat.cpp
+++ b/protocols/Yahoo/chat.cpp
@@ -1,19 +1,54 @@
/*
- * $Id: chat.cpp 9334 2009-04-04 21:56:36Z gena01 $
*
* myYahoo Miranda Plugin
*
* Authors: Gennady Feldman (aka Gena01)
* Laurent Marechal (aka Peorth)
+ * Boris Krasnovskiy (aka borkra)
*
* This code is under GPL and is based on AIM, MSN and Miranda source code.
* I want to thank Robert Rainwater and George Hazan for their code and support
* and for answering some of my questions during development of this plugin.
*/
#include "yahoo.h"
+#include "resource.h"
#include <m_protosvc.h>
#include <m_langpack.h>
#include <m_message.h>
+#include <m_chat.h>
+#include <m_userinfo.h>
+#include <m_history.h>
+#include <m_clc.h>
+
+struct InviteChatParam
+{
+ char* room;
+ CYahooProto* ppro;
+
+
+ InviteChatParam(const char* room, CYahooProto* ppro)
+ : room(strdup(room)), ppro(ppro) {}
+
+ ~InviteChatParam()
+ { free(room); }
+};
+
+struct InviteChatReqParam
+{
+ char* room;
+ char* who;
+ TCHAR* msg;
+ CYahooProto* ppro;
+
+ InviteChatReqParam(const char* room, const char* who, const char* msg, CYahooProto* ppro)
+ : room(mir_strdup(room)), who(mir_strdup(who)), msg(mir_utf8decodeT(msg)), ppro(ppro) {}
+
+ ~InviteChatReqParam()
+ { mir_free(room); mir_free(who); mir_free(msg); }
+};
+
+INT_PTR CALLBACK InviteToChatDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+void CALLBACK ConferenceRequestCB(PVOID dwParam);
/* Conference handlers */
void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const char *room, const char *msg, YList *members)
@@ -21,25 +56,94 @@ void ext_yahoo_got_conf_invite(int id, const char *me, const char *who, const ch
char z[1024];
_snprintf(z, sizeof(z), Translate("[miranda] Got conference invite to room: %s with msg: %s"), room ?room:"", msg ?msg:"");
LOG(("[ext_yahoo_got_conf_invite] %s", z));
- GETPROTOBYID( id )->ext_got_im("me", who, 0, z, 0, 0, 1, -1);
-
- yahoo_conference_decline(id, NULL, members, room, Translate("I am sorry, but i can't join your conference since this feature is not currently implemented in my client."));
+
+ CYahooProto* ppro = getProtoById(id);
+ if (!ppro) return;
+
+ bool freeList = true;
+ CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
+ if (!cm)
+ {
+ if (strcmp(who, me))
+ {
+ cm = new CYahooProto::ChatRoom(room, members);
+ ppro->m_chatrooms.insert(cm);
+
+ InviteChatReqParam* req = new InviteChatReqParam(room, who, msg, ppro);
+ CallFunctionAsync(ConferenceRequestCB, req);
+ freeList = false;
+ }
+ else
+ {
+ cm = new CYahooProto::ChatRoom(room, NULL);
+ ppro->m_chatrooms.insert(cm);
+ ppro->ChatStart(room);
+
+ yahoo_conference_logon(id, NULL, members, room);
+ }
+ }
+
+ if (freeList)
+ {
+ for (YList *l = members; l; l = l->next) free(l->data);
+ y_list_free(members);
+ }
}
void ext_yahoo_conf_userdecline(int id, const char *me, const char *who, const char *room, const char *msg)
{
+ TCHAR info[1024];
+ TCHAR *whot = mir_utf8decodeT(who);
+ TCHAR *msgt = mir_utf8decodeT(msg);
+ mir_sntprintf(info, SIZEOF(info), TranslateT("%s denied invitation with message: %s"), whot, msgt ? msgt : _T(""));
+ GETPROTOBYID(id)->ChatEvent(room, who, GC_EVENT_INFORMATION, info);
+ mir_free(msgt);
+ mir_free(whot);
}
void ext_yahoo_conf_userjoin(int id, const char *me, const char *who, const char *room)
{
+ CYahooProto* ppro = getProtoById(id);
+ if (!ppro) return;
+
+ CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
+ for (YList *l = cm->members; l; l = l->next)
+ {
+ if (!strcmp(who, (char*)l->data))
+ return;
+ }
+
+ cm->members = y_list_append(cm->members, strdup(who));
+ ppro->ChatEvent(room, who, GC_EVENT_JOIN);
}
void ext_yahoo_conf_userleave(int id, const char *me, const char *who, const char *room)
{
+ CYahooProto* ppro = getProtoById(id);
+ if (!ppro) return;
+
+ CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
+ if (!cm) return;
+
+ for (YList *l = cm->members; l; l = l->next)
+ {
+ if (strcmp((char*)l->data, who) == 0)
+ {
+ free(l->data);
+ y_list_remove_link(cm->members, l);
+ y_list_free_1(l);
+ break;
+ }
+ }
+
+ ppro->ChatEvent(room, who, GC_EVENT_PART);
}
void ext_yahoo_conf_message(int id, const char *me, const char *who, const char *room, const char *msg, int utf8)
{
+ TCHAR *msgt = utf8 ? mir_utf8decodeT(msg) : mir_a2t(msg);
+ GETPROTOBYID(id)->ChatEvent(room, who, GC_EVENT_MESSAGE, msgt);
+ mir_free(msgt);
}
/* chat handlers */
@@ -49,6 +153,8 @@ void ext_yahoo_chat_cat_xml(int id, const char *xml)
void ext_yahoo_chat_join(int id, const char *me, const char *room, const char * topic, YList *members, int fd)
{
+ for (YList *l = members; l; l = l->next) free(l->data);
+ y_list_free(members);
}
void ext_yahoo_chat_userjoin(int id, const char *me, const char *room, struct yahoo_chat_member *who)
@@ -70,3 +176,506 @@ void ext_yahoo_chat_yahooerror(int id, const char *me)
{
LOG(("got chat error"));
}
+
+static const COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+
+void CYahooProto::ChatRegister(void)
+{
+ GCREGISTER gcr = {0};
+ gcr.cbSize = sizeof(gcr);
+ gcr.dwFlags = GC_TYPNOTIF | GC_CHANMGR | GC_TCHAR;
+ gcr.iMaxText = 0;
+ gcr.nColors = 16;
+ gcr.pColors = (COLORREF*)crCols;
+ gcr.ptszModuleDispName = m_tszUserName;
+ gcr.pszModule = m_szModuleName;
+ CallServiceSync(MS_GC_REGISTER, 0, (LPARAM)&gcr);
+
+ YHookEvent(ME_GC_EVENT, &CYahooProto::OnGCEventHook);
+ YHookEvent(ME_GC_BUILDMENU, &CYahooProto::OnGCMenuHook);
+}
+
+void CYahooProto::ChatStart(const char* room)
+{
+ TCHAR* idt = mir_a2t(room);
+
+ GCSESSION gcw = {0};
+ gcw.cbSize = sizeof(gcw);
+ gcw.dwFlags = GC_TCHAR;
+ gcw.iType = GCW_CHATROOM;
+ gcw.pszModule = m_szModuleName;
+ gcw.ptszName = idt;
+ gcw.ptszID = idt;
+ CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
+
+ GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
+ gcd.ptszID = idt;
+
+ GCEVENT gce = {0};
+ gce.cbSize = sizeof(gce);
+ gce.dwFlags = GC_TCHAR;
+ gce.pDest = &gcd;
+ gce.ptszStatus = TranslateT("Me");
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ gcd.iType = GC_EVENT_ADDGROUP;
+ gce.ptszStatus = TranslateT("Others");
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ gcd.iType = GC_EVENT_CONTROL;
+ CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);
+
+ mir_free(idt);
+}
+
+void CYahooProto::ChatLeave(const char* room)
+{
+ TCHAR* idt = mir_a2t(room);
+
+ GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_CONTROL };
+ gcd.ptszID = idt;
+
+ GCEVENT gce = {0};
+ gce.cbSize = sizeof(GCEVENT);
+ gce.dwFlags = GC_TCHAR | GCEF_REMOVECONTACT;
+ gce.pDest = &gcd;
+ CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, (LPARAM)&gce);
+ CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
+
+ mir_free(idt);
+}
+
+void CYahooProto::ChatLeaveAll(void)
+{
+ for (int i = 0; i < m_chatrooms.getCount(); ++i)
+ ChatLeave(m_chatrooms[i].name);
+}
+
+void CYahooProto::ChatEvent(const char* room, const char* who, int evt, const TCHAR* msg)
+{
+ TCHAR* idt = mir_a2t(room);
+ TCHAR* snt = mir_a2t(who);
+
+ HANDLE hContact = getbuddyH(who);
+ TCHAR* nick = hContact ? (TCHAR*)YAHOO_CallService(MS_CLIST_GETCONTACTDISPLAYNAME, WPARAM(hContact), GCDNF_TCHAR) : snt;
+
+ GCDEST gcd = { m_szModuleName, { NULL }, evt };
+ gcd.ptszID = idt;
+
+ GCEVENT gce = {0};
+ gce.cbSize = sizeof(gce);
+ gce.dwFlags = GC_TCHAR | GCEF_ADDTOLOG;
+ gce.pDest = &gcd;
+ gce.ptszNick = nick;
+ gce.ptszUID = snt;
+ gce.bIsMe = _stricmp(who, m_yahoo_id) == 0;
+ gce.ptszStatus = gce.bIsMe ? TranslateT("Me") : TranslateT("Others");
+ gce.ptszText = msg;
+ gce.time = time(NULL);
+ CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
+
+ mir_free(snt);
+ mir_free(idt);
+}
+
+int __cdecl CYahooProto::OnGCEventHook(WPARAM, LPARAM lParam)
+{
+ GCHOOK *gch = (GCHOOK*) lParam;
+ if (!gch) return 1;
+
+ if (strcmp(gch->pDest->pszModule, m_szModuleName)) return 0;
+
+ char* room = mir_t2a(gch->pDest->ptszID);
+ char* who = mir_t2a(gch->ptszUID);
+
+ switch (gch->pDest->iType)
+ {
+ case GC_SESSION_TERMINATE:
+ {
+ ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
+ if (cm)
+ {
+ yahoo_conference_logoff(m_id, NULL, cm->members, room);
+ m_chatrooms.remove((ChatRoom*)&room);
+ }
+ }
+ break;
+
+ case GC_USER_MESSAGE:
+ if (gch->ptszText && gch->ptszText[0])
+ {
+ char* msg = mir_utf8encodeT(gch->ptszText);
+ ChatRoom *cm = m_chatrooms.find((ChatRoom*)&room);
+ if (cm)
+ yahoo_conference_message(m_id, NULL, cm->members, room, msg, 1);
+ mir_free(msg);
+ }
+ break;
+
+ case GC_USER_CHANMGR:
+ DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
+ LPARAM(new InviteChatParam(room, this)));
+ break;
+
+ case GC_USER_PRIVMESS:
+ YAHOO_CallService(MS_MSG_SENDMESSAGE, (WPARAM)getbuddyH(who), 0);
+ break;
+
+ case GC_USER_LOGMENU:
+ switch(gch->dwData)
+ {
+ case 10:
+ DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, InviteToChatDialog,
+ LPARAM(new InviteChatParam(room, this)));
+ break;
+
+ case 20:
+ ChatLeave(room);
+ break;
+ }
+ break;
+
+ case GC_USER_NICKLISTMENU:
+ switch (gch->dwData)
+ {
+ case 10:
+ YAHOO_CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)getbuddyH(who), 0);
+ break;
+
+ case 20:
+ YAHOO_CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)getbuddyH(who), 0);
+ break;
+
+ case 110:
+ ChatLeave(room);
+ break;
+ }
+ break;
+
+ case GC_USER_TYPNOTIFY:
+ break;
+ }
+ mir_free(who);
+ mir_free(room);
+
+ return 0;
+}
+
+int __cdecl CYahooProto::OnGCMenuHook(WPARAM, LPARAM lParam)
+{
+ GCMENUITEMS *gcmi = (GCMENUITEMS*) lParam;
+
+ if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;
+
+ if (gcmi->Type == MENU_ON_LOG)
+ {
+ static const struct gc_item Items[] =
+ {
+ { TranslateT("&Invite user..."), 10, MENU_ITEM, FALSE },
+ { TranslateT("&Leave chat session"), 20, MENU_ITEM, FALSE }
+ };
+ gcmi->nItems = SIZEOF(Items);
+ gcmi->Item = (gc_item*)Items;
+ }
+ else if (gcmi->Type == MENU_ON_NICKLIST)
+ {
+ char* id = mir_t2a(gcmi->pszUID);
+ if (!_stricmp(m_yahoo_id, id))
+ {
+ static const struct gc_item Items[] =
+ {
+ { TranslateT("User &details"), 10, MENU_ITEM, FALSE },
+ { TranslateT("User &history"), 20, MENU_ITEM, FALSE },
+ { _T(""), 100, MENU_SEPARATOR, FALSE },
+ { TranslateT("&Leave chat session"), 110, MENU_ITEM, FALSE }
+ };
+ gcmi->nItems = SIZEOF(Items);
+ gcmi->Item = (gc_item*)Items;
+ }
+ else
+ {
+ static const struct gc_item Items[] =
+ {
+ { TranslateT("User &details"), 10, MENU_ITEM, FALSE },
+ { TranslateT("User &history"), 20, MENU_ITEM, FALSE }
+ };
+ gcmi->nItems = SIZEOF(Items);
+ gcmi->Item = (gc_item*)Items;
+ }
+ mir_free(id);
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Invite to chat dialog
+
+static void clist_chat_invite_send(HANDLE hItem, HWND hwndList, YList* &who, char* room, CYahooProto* ppro, TCHAR *msg)
+{
+ bool root = !hItem;
+ if (root)
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
+
+ while (hItem)
+ {
+ if (IsHContactGroup(hItem))
+ {
+ HANDLE hItemT = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
+ if (hItemT) clist_chat_invite_send(hItemT, hwndList, who, room, ppro, msg);
+ }
+ else
+ {
+ int chk = SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0);
+ if (chk)
+ {
+ if (IsHContactInfo(hItem))
+ {
+ TCHAR buf[128] = _T("");
+ SendMessage(hwndList, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)buf);
+
+ who = y_list_append(who, mir_t2a(buf));
+ }
+ else
+ {
+ DBVARIANT dbv;
+ if (!ppro->GetString(hItem, YAHOO_LOGINID, &dbv))
+ who = y_list_append(who, dbv.pszVal);
+ }
+ }
+ }
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
+ }
+
+ if (root && who)
+ {
+ char *msg8 = mir_utf8encodeT(msg);
+ CYahooProto::ChatRoom *cm = ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&room);
+ if (cm)
+ {
+ for (YList *l = who; l; l = l->next)
+ yahoo_conference_addinvite(ppro->m_id, NULL, (char*)l->data, room, cm->members, msg8);
+ }
+ else
+ yahoo_conference_invite(ppro->m_id, NULL, who, room, msg8);
+
+ mir_free(msg8);
+
+ for (YList *l = who; l; l = l->next) mir_free(l->data);
+ y_list_free(who);
+ }
+}
+
+static void ClistValidateContact(HANDLE hItem, HWND hwndList, CYahooProto* ppro)
+{
+ if (!ppro->IsMyContact(hItem) || ppro->GetByte(hItem, "ChatRoom", 0) ||
+ ppro->GetWord(hItem, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONTHEPHONE)
+ SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0);
+}
+
+static void ClistChatPrepare(HANDLE hItem, HWND hwndList, CYahooProto* ppro)
+{
+ if (hItem == NULL)
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
+
+ while (hItem)
+ {
+ HANDLE hItemN = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
+
+ if (IsHContactGroup(hItem))
+ {
+ HANDLE hItemT = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
+ if (hItemT) ClistChatPrepare(hItemT, hwndList, ppro);
+ }
+ else if (IsHContactContact(hItem))
+ ClistValidateContact(hItem, hwndList, ppro);
+
+ hItem = hItemN;
+ }
+}
+
+INT_PTR CALLBACK InviteToChatDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ InviteChatParam* param = (InviteChatParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ param = (InviteChatParam*)lParam;
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)param->ppro->LoadIconEx("yahoo", true));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)param->ppro->LoadIconEx("yahoo"));
+
+ SetDlgItemTextA(hwndDlg, IDC_ROOMNAME, param->room);
+ SetDlgItemText(hwndDlg, IDC_MSG, TranslateT("Join My Conference..."));
+ break;
+
+ case WM_CLOSE:
+ EndDialog(hwndDlg, 0);
+ break;
+
+ case WM_NCDESTROY:
+ param->ppro->ReleaseIconEx("yahoo", true);
+ param->ppro->ReleaseIconEx("yahoo");
+ delete param;
+ break;
+
+ case WM_NOTIFY:
+ {
+ NMCLISTCONTROL* nmc = (NMCLISTCONTROL*)lParam;
+ if (nmc->hdr.idFrom == IDC_CCLIST)
+ {
+ switch (nmc->hdr.code)
+ {
+ case CLN_NEWCONTACT:
+ if (param && (nmc->flags & (CLNF_ISGROUP | CLNF_ISINFO)) == 0)
+ ClistValidateContact(nmc->hItem, nmc->hdr.hwndFrom, param->ppro);
+ break;
+
+ case CLN_LISTREBUILT:
+ if (param)
+ ClistChatPrepare(NULL, nmc->hdr.hwndFrom, param->ppro);
+ break;
+ }
+ }
+ }
+ break;
+
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_ADDSCR:
+ if (param->ppro->m_bLoggedIn)
+ {
+ TCHAR sn[64];
+ GetDlgItemText(hwndDlg, IDC_EDITSCR, sn, SIZEOF(sn));
+
+ CLCINFOITEM cii = {0};
+ cii.cbSize = sizeof(cii);
+ cii.flags = CLCIIF_CHECKBOX | CLCIIF_BELOWCONTACTS;
+ cii.pszText = sn;
+
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
+ SendDlgItemMessage(hwndDlg, IDC_CCLIST, CLM_SETCHECKMARK, (LPARAM)hItem, 1);
+ }
+ break;
+
+ case IDOK:
+ {
+ TCHAR msg[1024];
+ GetDlgItemText(hwndDlg, IDC_MSG, msg, sizeof(msg));
+
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_CCLIST);
+ YList *who = NULL;
+ clist_chat_invite_send(NULL, hwndList, who, param->room, param->ppro, msg);
+
+ EndDialog(hwndDlg, IDOK);
+ PostMessage(hwndDlg, WM_DESTROY, 0, 0);
+ }
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ PostMessage(hwndDlg, WM_DESTROY, 0, 0);
+ break;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Chat request dialog
+
+INT_PTR CALLBACK ChatRequestDialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ InviteChatReqParam* param = (InviteChatReqParam*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ param = (InviteChatReqParam*)lParam;
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)param->ppro->LoadIconEx("yahoo", true));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)param->ppro->LoadIconEx("yahoo"));
+
+ SetDlgItemTextA(hwndDlg, IDC_SCREENNAME, param->who);
+ SetDlgItemText(hwndDlg, IDC_MSG, param->msg);
+ SetDlgItemText(hwndDlg, IDC_MSG2, TranslateT("No, thank you..."));
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hwndDlg);
+ break;
+
+ case WM_NCDESTROY:
+ param->ppro->ReleaseIconEx("yahoo", true);
+ param->ppro->ReleaseIconEx("yahoo");
+ delete param;
+ break;
+
+ case WM_COMMAND:
+ {
+ CYahooProto::ChatRoom *cm = param->ppro->m_chatrooms.find((CYahooProto::ChatRoom*)&param->room);
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ if (cm)
+ {
+ param->ppro->ChatStart(param->room);
+
+ for (YList *l = cm->members; l; l = l->next)
+ param->ppro->ChatEvent(param->room, (char*)l->data, GC_EVENT_JOIN);
+
+ yahoo_conference_logon(param->ppro->m_id, NULL, cm->members, param->room);
+ }
+ DestroyWindow(hwndDlg);
+ break;
+
+ case IDCANCEL:
+ if (cm)
+ {
+ TCHAR msg[1024];
+ GetDlgItemText(hwndDlg, IDC_MSG2, msg, SIZEOF(msg));
+ char *msg8 = mir_utf8encodeT(msg);
+ yahoo_conference_decline(param->ppro->m_id, NULL, cm->members, param->room, msg8);
+ mir_free(msg8);
+
+ param->ppro->m_chatrooms.remove((CYahooProto::ChatRoom*)&param->room);
+ }
+ DestroyWindow(hwndDlg);
+ break;
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
+static void CALLBACK ConferenceRequestCB(PVOID pParam)
+{
+ CreateDialogParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE_REQ),
+ NULL, ChatRequestDialog, (LPARAM)pParam);
+}
+
+INT_PTR __cdecl CYahooProto::CreateConference(WPARAM /*wParam*/, LPARAM /*lParam*/)
+{
+ char room[128];
+ mir_snprintf(room, sizeof(room), "%s-%u", m_yahoo_id, time(NULL));
+
+ InviteChatParam* param = new InviteChatParam(room, this);
+ DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL,
+ InviteToChatDialog, LPARAM(param));
+ return 0;
+}
+
diff --git a/protocols/Yahoo/proto.cpp b/protocols/Yahoo/proto.cpp
index 1fc2ef8af8..a79d3cfbf7 100644
--- a/protocols/Yahoo/proto.cpp
+++ b/protocols/Yahoo/proto.cpp
@@ -29,7 +29,9 @@
#endif
CYahooProto::CYahooProto( const char* aProtoName, const TCHAR* aUserName ) :
- m_bLoggedIn( FALSE ), poll_loop( 0 )
+ m_bLoggedIn( FALSE ),
+ poll_loop( 0 ),
+ m_chatrooms(3, ChatRoom::compare)
{
m_iVersion = 2;
m_tszUserName = mir_tstrdup( aUserName );
@@ -58,7 +60,8 @@ CYahooProto::~CYahooProto()
DestroyHookableEvent(hYahooNudge);
MenuUninit();
-
+
+ m_chatrooms.destroy();
mir_free( m_szModuleName );
mir_free( m_tszUserName );
@@ -71,9 +74,7 @@ CYahooProto::~CYahooProto()
////////////////////////////////////////////////////////////////////////////////////////
// OnModulesLoadedEx - performs hook registration
-//static COLORREF crCols[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
-
-INT_PTR CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM )
+int CYahooProto::OnModulesLoadedEx( WPARAM, LPARAM )
{
YHookEvent( ME_USERINFO_INITIALISE, &CYahooProto::OnUserInfoInit );
YHookEvent( ME_IDLE_CHANGED, &CYahooProto::OnIdleEvent);
diff --git a/protocols/Yahoo/proto.h b/protocols/Yahoo/proto.h
index 539bd2a6b3..bf41f53104 100644
--- a/protocols/Yahoo/proto.h
+++ b/protocols/Yahoo/proto.h
@@ -28,7 +28,7 @@ extern "C"
}
#else
typedef void ( __cdecl CYahooProto::*YThreadFunc )( void* );
- typedef INT_PTR ( __cdecl CYahooProto::*YEventFunc )( WPARAM, LPARAM );
+ typedef int ( __cdecl CYahooProto::*YEventFunc )( WPARAM, LPARAM );
typedef INT_PTR ( __cdecl CYahooProto::*YServiceFunc )( WPARAM, LPARAM );
typedef INT_PTR ( __cdecl CYahooProto::*YServiceFuncParam )( WPARAM, LPARAM, LPARAM );
#endif
@@ -98,12 +98,14 @@ struct CYahooProto : public PROTO_INTERFACE
virtual int __cdecl OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam );
//====| Events |======================================================================
- INT_PTR __cdecl OnContactDeleted( WPARAM, LPARAM );
- INT_PTR __cdecl OnIdleEvent( WPARAM, LPARAM );
- INT_PTR __cdecl OnModulesLoadedEx( WPARAM, LPARAM );
- INT_PTR __cdecl OnOptionsInit( WPARAM, LPARAM );
- INT_PTR __cdecl OnSettingChanged( WPARAM, LPARAM );
+ int __cdecl OnContactDeleted( WPARAM, LPARAM );
+ int __cdecl OnIdleEvent( WPARAM, LPARAM );
+ int __cdecl OnModulesLoadedEx( WPARAM, LPARAM );
+ int __cdecl OnOptionsInit( WPARAM, LPARAM );
+ int __cdecl OnSettingChanged( WPARAM, LPARAM );
+ int __cdecl OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam);
+ //====| Services |====================================================================
INT_PTR __cdecl OnABCommand( WPARAM, LPARAM );
INT_PTR __cdecl OnCalendarCommand( WPARAM, LPARAM );
INT_PTR __cdecl OnEditMyProfile( WPARAM, LPARAM );
@@ -111,14 +113,15 @@ struct CYahooProto : public PROTO_INTERFACE
INT_PTR __cdecl OnRefreshCommand( WPARAM, LPARAM );
INT_PTR __cdecl OnShowMyProfileCommand( WPARAM, LPARAM );
INT_PTR __cdecl OnShowProfileCommand( WPARAM, LPARAM );
- INT_PTR __cdecl OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam);
- //====| Services |====================================================================
INT_PTR __cdecl SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl GetUnreadEmailCount( WPARAM, LPARAM );
INT_PTR __cdecl SendNudge( WPARAM, LPARAM );
INT_PTR __cdecl SetMyAvatar( WPARAM, LPARAM );
+ INT_PTR __cdecl CreateConference(WPARAM /*wParam*/, LPARAM /*lParam*/);
+
+
void BroadcastStatus(int s);
void LoadYahooServices( void );
void MenuMainInit( void );
@@ -129,6 +132,24 @@ struct CYahooProto : public PROTO_INTERFACE
BOOL m_bLoggedIn;
YList *m_connections;
unsigned int m_connection_tags;
+
+ struct ChatRoom
+ {
+ char *name;
+ YList *members;
+
+ ChatRoom(const char* name, YList *members)
+ : name(strdup(name)), members(members) {}
+
+ ~ChatRoom()
+ { for (YList *l = members; l; l = l->next) free(l->data);
+ free(name); y_list_free(members); }
+
+ static int compare(const ChatRoom* c1, const ChatRoom* c2)
+ { return strcmp(c1->name, c2->name); }
+ };
+
+ OBJLIST <ChatRoom> m_chatrooms;
char* m_startMsg;
@@ -163,6 +184,16 @@ struct CYahooProto : public PROTO_INTERFACE
void SendAvatar(const TCHAR *szFile);
void GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, int cbLen, int type);
+ //====| chat.cpp |====================================================================
+ void ChatRegister(void);
+ void ChatStart(const char* room);
+ void ChatEvent(const char* room, const char* who, int evt, const TCHAR* msg = NULL);
+ void ChatLeave(const char* room);
+ void ChatLeaveAll(void);
+
+ int __cdecl OnGCEventHook(WPARAM, LPARAM lParam);
+ int __cdecl OnGCMenuHook(WPARAM, LPARAM lParam);
+
//====| filetransfer.cpp |============================================================
void __cdecl recv_filethread(void *psf);
void __cdecl send_filethread(void *psf);
@@ -215,7 +246,7 @@ struct CYahooProto : public PROTO_INTERFACE
INT_PTR __cdecl SetCustomStatCommand( WPARAM, LPARAM );
//====| user_info.cpp |===============================================================
- INT_PTR __cdecl OnUserInfoInit( WPARAM wParam, LPARAM lParam );
+ int __cdecl OnUserInfoInit( WPARAM wParam, LPARAM lParam );
//====| util.cpp |====================================================================
int GetByte( const char* valueName, int parDefltValue );
@@ -247,6 +278,7 @@ struct CYahooProto : public PROTO_INTERFACE
int ShowNotification(const char *title, const char *info, DWORD flags);
void ShowError(const char *title, const char *buff);
int ShowPopup( const char* nickname, const char* msg, const char *szURL );
+ bool IsMyContact(HANDLE hContact);
#ifdef __GNUC__
int DebugLog( const char *fmt, ... ) __attribute__ ((format(printf,2,3)));
@@ -312,7 +344,7 @@ private:
HGENMENU mainMenuRoot;
HGENMENU hShowProfileMenuItem;
- HGENMENU menuItemsAll[ 7 ];
+ HGENMENU menuItemsAll[ 8 ];
HANDLE hYahooAvatarsFolder;
bool InitCstFldRan;
diff --git a/protocols/Yahoo/resource.h b/protocols/Yahoo/resource.h
index 0e182c3c17..ba15e24ad2 100644
--- a/protocols/Yahoo/resource.h
+++ b/protocols/Yahoo/resource.h
@@ -30,6 +30,8 @@
#define IDD_SETCUSTSTAT 186
#define IDD_OPT_YAHOO_POPUP 187
+#define IDD_CHATROOM_INVITE 188
+#define IDD_CHATROOM_INVITE_REQ 189
#define IDC_CUSTSTATBUSY 1000
#define IDC_CUSTSTAT 1001
@@ -58,6 +60,13 @@
#define IDC_SHOW_AVATARS 1479
#define IDC_MAIL_AUTOLOGIN 1480
#define IDC_YAHOO_JAPAN 1481
+#define IDC_MSG 1482
+#define IDC_ROOMNAME 1483
+#define IDC_CCLIST 1484
+#define IDC_EDITSCR 1485
+#define IDC_ADDSCR 1486
+#define IDC_SCREENNAME 1487
+#define IDC_MSG2 1488
/*
* Ignore Options
@@ -84,8 +93,3 @@
*/
#define IDD_USER_INFO 500
#define IDC_NFO_CLIENT 501
-
-/*
- *
- */
-#define IDC_STATIC -1
diff --git a/protocols/Yahoo/server.cpp b/protocols/Yahoo/server.cpp
index 0a6886e037..34ccfe8dc3 100644
--- a/protocols/Yahoo/server.cpp
+++ b/protocols/Yahoo/server.cpp
@@ -111,12 +111,6 @@ void __cdecl CYahooProto::server_main(void *empty)
}
recvResult = CallService(MS_NETLIB_SELECTEX, (WPARAM) 0, (LPARAM)&nls);
- /* Check for Miranda Exit Status */
- if (Miranda_Terminated()) {
- DebugLog("Miranda Exiting... stopping the loop.");
- break;
- }
-
/* do the timer check */
if (m_id > 0) {
#ifdef HTTP_GATEWAY
@@ -190,12 +184,15 @@ void __cdecl CYahooProto::server_main(void *empty)
}
} // if c->fd == nls
}// for i = 0
-
}
-
-
+
}// for l=connections
+ /* Check for Miranda Exit Status */
+ if (Miranda_Terminated()) {
+ DebugLog("Miranda Exiting... stopping the loop.");
+ break;
+ }
}
DebugLog("Exited loop");
diff --git a/protocols/Yahoo/services.cpp b/protocols/Yahoo/services.cpp
index 363c000ad2..e36a27163c 100644
--- a/protocols/Yahoo/services.cpp
+++ b/protocols/Yahoo/services.cpp
@@ -34,7 +34,7 @@ void CYahooProto::logoff_buddies()
HANDLE hContact = ( HANDLE )YAHOO_CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
while ( hContact != NULL )
{
- if ( !lstrcmpA( m_szModuleName, ( char* )YAHOO_CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact,0 ))) {
+ if (IsMyContact(hContact)) {
SetWord( hContact, "Status", ID_STATUS_OFFLINE );
SetDword(hContact, "IdleTS", 0);
SetDword(hContact, "PictLastCheck", 0);
@@ -87,7 +87,7 @@ void CYahooProto::BroadcastStatus(int s)
//=======================================================
//Contact deletion event
//=======================================================
-INT_PTR __cdecl CYahooProto::OnContactDeleted( WPARAM wParam, LPARAM lParam )
+int __cdecl CYahooProto::OnContactDeleted( WPARAM wParam, LPARAM lParam )
{
DBVARIANT dbv;
HANDLE hContact = (HANDLE) wParam;
@@ -340,7 +340,7 @@ INT_PTR __cdecl CYahooProto::OnRefreshCommand( WPARAM wParam, LPARAM lParam )
return 0;
}
-INT_PTR __cdecl CYahooProto::OnIdleEvent(WPARAM wParam, LPARAM lParam)
+int __cdecl CYahooProto::OnIdleEvent(WPARAM wParam, LPARAM lParam)
{
BOOL bIdle = (lParam & IDF_ISIDLE);
@@ -454,6 +454,14 @@ void CYahooProto::MenuMainInit( void )
mi.icolibItem = GetIconHandle( IDI_CALENDAR );
mi.pszName = LPGEN( "&Calendar" );
menuItemsAll[5] = Menu_AddProtoMenuItem(&mi);
+ strcpy( tDest, "/JoinChatRoom" );
+ YCreateService("/JoinChatRoom", &CYahooProto::CreateConference);
+
+ mi.position = 290018;
+ mi.icolibItem = GetIconHandle(IDI_YAHOO);
+ mi.pszName = LPGEN("Create Conference");
+ menuItemsAll[6] = Menu_AddProtoMenuItem(&mi);
+
// Show Refresh
/*strcpy( tDest, YAHOO_REFRESH );
@@ -462,7 +470,7 @@ void CYahooProto::MenuMainInit( void )
mi.position = 500090015;
mi.icolibItem = GetIconHandle( IDI_REFRESH );
mi.pszName = LPGEN( "&Refresh" );
- menuItemsAll[6] = Menu_AddProtoMenuItem(&mi);
+ menuItemsAll[7] = Menu_AddProtoMenuItem(&mi);
*/
}
@@ -497,16 +505,14 @@ void CYahooProto::MenuUninit( void )
YAHOO_CallService( MS_CLIST_REMOVECONTACTMENUITEM, ( WPARAM )hShowProfileMenuItem, 0 );
}
-INT_PTR __cdecl CYahooProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
+int __cdecl CYahooProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
{
const HANDLE hContact = (HANDLE)wParam;
- char *szProto;
CLISTMENUITEM mi = {0};
mi.cbSize = sizeof(mi);
- szProto = ( char* )YAHOO_CallService( MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0 );
- if ( szProto == NULL || lstrcmpA( szProto, m_szModuleName )) {
+ if (!IsMyContact(hContact)) {
DebugLog("[OnPrebuildContactMenu] Not a Yahoo Contact!!!");
return 0;
}
diff --git a/protocols/Yahoo/user_info.cpp b/protocols/Yahoo/user_info.cpp
index 77b06344f6..4447506397 100644
--- a/protocols/Yahoo/user_info.cpp
+++ b/protocols/Yahoo/user_info.cpp
@@ -122,15 +122,12 @@ INT_PTR __cdecl CYahooProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam )
odp.dwInitParam = ( LPARAM )this;
HANDLE hContact = ( HANDLE )lParam;
- if ( hContact ) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto != NULL && !strcmp( szProto, m_szModuleName )) {
- odp.pfnDlgProc = YahooUserInfoDlgProc;
- odp.position = -1900000000;
- odp.pszTemplate = MAKEINTRESOURCEA( IDD_USER_INFO );
- odp.pszTitle = m_szModuleName;
- UserInfo_AddPage(wParam, &odp);
- }
+ if ( IsMyContact(hContact)) {
+ odp.pfnDlgProc = YahooUserInfoDlgProc;
+ odp.position = -1900000000;
+ odp.pszTemplate = MAKEINTRESOURCEA( IDD_USER_INFO );
+ odp.pszTitle = m_szModuleName;
+ UserInfo_AddPage(wParam, &odp);
}
return 0;
diff --git a/protocols/Yahoo/util.cpp b/protocols/Yahoo/util.cpp
index 6be9439380..62afef5a56 100644
--- a/protocols/Yahoo/util.cpp
+++ b/protocols/Yahoo/util.cpp
@@ -301,7 +301,7 @@ void CYahooProto::ShowError(const char *title, const char *buff)
ShowNotification(title, buff, NIIF_ERROR);
}
-INT_PTR __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam)
+int __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
@@ -322,6 +322,14 @@ INT_PTR __cdecl CYahooProto::OnSettingChanged(WPARAM wParam, LPARAM lParam)
return 0;
}
+bool CYahooProto::IsMyContact(HANDLE hContact)
+{
+ if (!hContact) return false;
+
+ char* szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ return szProto && !strcmp(szProto, m_szModuleName);
+}
+
char* YAHOO_GetContactName( HANDLE hContact )
{
return ( char* )YAHOO_CallService( MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0 );
diff --git a/protocols/Yahoo/yahoo.cpp b/protocols/Yahoo/yahoo.cpp
index b39e243d8f..dbec251ef1 100644
--- a/protocols/Yahoo/yahoo.cpp
+++ b/protocols/Yahoo/yahoo.cpp
@@ -219,8 +219,10 @@ void CYahooProto::logout()
{
LOG(("[yahoo_logout]"));
- if (m_bLoggedIn)
+ if (m_bLoggedIn) {
+ ChatLeaveAll();
yahoo_logoff(m_id);
+ }
/* need to stop the server and close all the connections */
poll_loop = 0;
@@ -282,15 +284,13 @@ void CYahooProto::AddBuddy(HANDLE hContact, const char *group, const TCHAR *msg)
HANDLE CYahooProto::getbuddyH(const char *yahoo_id)
{
- char *szProto;
HANDLE hContact;
for ( hContact = ( HANDLE )YAHOO_CallService( MS_DB_CONTACT_FINDFIRST, 0, 0 );
hContact != NULL;
hContact = ( HANDLE )YAHOO_CallService( MS_DB_CONTACT_FINDNEXT, ( WPARAM )hContact, 0 ))
{
- szProto = ( char* )YAHOO_CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact, 0 );
- if ( szProto != NULL && !lstrcmpA( szProto, m_szModuleName ))
+ if (IsMyContact(hContact))
{
DBVARIANT dbv;
if (GetString(hContact, YAHOO_LOGINID, &dbv))
@@ -557,7 +557,7 @@ void CYahooProto::ext_status_logon(const char *who, int protocol, int stat, cons
if (cksum == 0 || cksum == -1) {
// no avatar
DBWriteContactSettingDword(hContact, m_szModuleName, "PictCK", 0);
- } else if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) != cksum) {
+ } else if (DBGetContactSettingDword(hContact, m_szModuleName,"PictCK", 0) != (unsigned)cksum) {
//char szFile[MAX_PATH];
// Save new Checksum
@@ -614,7 +614,6 @@ void CYahooProto::ext_got_stealth(char *stealthlist)
char **s;
int found = 0;
char **stealth = NULL;
- char *szProto;
HANDLE hContact;
LOG(("[ext_got_stealth] list: %s", stealthlist));
@@ -626,8 +625,7 @@ void CYahooProto::ext_got_stealth(char *stealthlist)
hContact != NULL;
hContact = ( HANDLE )YAHOO_CallService( MS_DB_CONTACT_FINDNEXT, ( WPARAM )hContact, 0 ))
{
- szProto = ( char* )YAHOO_CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM )hContact, 0 );
- if ( szProto != NULL && !lstrcmpA( szProto, m_szModuleName )) {
+ if (IsMyContact(hContact)) {
DBVARIANT dbv;
if (GetString( hContact, YAHOO_LOGINID, &dbv))
continue;