diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-08 19:39:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-08 19:39:48 +0000 |
commit | 05cd7934d4bdb097e112efdda356946868f3f5d6 (patch) | |
tree | 0fa678b494af8b994abf7319298a1af06fc9218a /protocols/Twitter/src/chat.cpp | |
parent | 50a2ba5bf6827b8f010288021c1797c11bd1531e (diff) |
- end of ANSI support in chats;
- manual crit section control removed from chat engine;
- bunch of memory-related clutches either removed or replaced with smart pointers
git-svn-id: http://svn.miranda-ng.org/main/trunk@7549 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Twitter/src/chat.cpp')
-rw-r--r-- | protocols/Twitter/src/chat.cpp | 86 |
1 files changed, 26 insertions, 60 deletions
diff --git a/protocols/Twitter/src/chat.cpp b/protocols/Twitter/src/chat.cpp index e657414295..cddcbcefca 100644 --- a/protocols/Twitter/src/chat.cpp +++ b/protocols/Twitter/src/chat.cpp @@ -22,16 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void TwitterProto::UpdateChat(const twitter_user &update)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_MESSAGE;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR|GCEF_ADDTOLOG;
- gce.pDest = &gcd;
- gce.ptszUID = mir_a2t(update.username.c_str());
- gce.bIsMe = (update.username == twit_.get_username());
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_MESSAGE };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.pDest = &gcd;
+ gce.bIsMe = (update.username == twit_.get_username());
+ gce.dwFlags = GCEF_ADDTOLOG;
+ gce.ptszUID = mir_a2t(update.username.c_str());
//TODO: write code here to replace % with %% in update.status.text (which is a std::string)
std::string chatText = update.status.text;
@@ -93,18 +89,12 @@ int TwitterProto::OnChatOutgoing(WPARAM wParam,LPARAM lParam) // TODO: remove nick?
void TwitterProto::AddChatContact(const char *name,const char *nick)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_JOIN;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
- gce.ptszNick = mir_a2t(nick ? nick:name);
- gce.ptszUID = mir_a2t(name);
- gce.bIsMe = false;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_JOIN };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = DWORD(time(0));
+ gce.ptszNick = mir_a2t(nick ? nick:name);
+ gce.ptszUID = mir_a2t(name);
gce.ptszStatus = _T("Normal");
- gce.time = static_cast<DWORD>(time(0));
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
mir_free(const_cast<TCHAR*>(gce.ptszNick));
@@ -113,16 +103,11 @@ void TwitterProto::AddChatContact(const char *name,const char *nick) void TwitterProto::DeleteChatContact(const char *name)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_PART;
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
- gce.ptszNick = mir_a2t(name);
- gce.ptszUID = gce.ptszNick;
- gce.time = static_cast<DWORD>(time(0));
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_PART };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = DWORD(time(0));
+ gce.ptszNick = mir_a2t(name);
+ gce.ptszUID = gce.ptszNick;
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
mir_free(const_cast<TCHAR*>(gce.ptszNick));
@@ -130,28 +115,20 @@ void TwitterProto::DeleteChatContact(const char *name) INT_PTR TwitterProto::OnJoinChat(WPARAM,LPARAM suppress)
{
- GCSESSION gcw = {sizeof(gcw)};
-
// ***** Create the group chat session
- gcw.dwFlags = GC_TCHAR;
- gcw.iType = GCW_CHATROOM;
+ GCSESSION gcw = { sizeof(gcw) };
+ gcw.iType = GCW_CHATROOM;
gcw.pszModule = m_szModuleName;
- gcw.ptszName = m_tszUserName;
- gcw.ptszID = m_tszUserName;
+ gcw.ptszName = m_tszUserName;
+ gcw.ptszID = m_tszUserName;
CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
if(m_iStatus != ID_STATUS_ONLINE)
return 0;
// ***** Create a group
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
-
- GCEVENT gce = {sizeof(gce)};
- gce.pDest = &gcd;
- gce.dwFlags = GC_TCHAR;
-
- gcd.iType = GC_EVENT_ADDGROUP;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_ADDGROUP };
+ GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszStatus = _T("Normal");
CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
@@ -170,29 +147,18 @@ INT_PTR TwitterProto::OnLeaveChat(WPARAM,LPARAM) {
in_chat_ = false;
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast<LPARAM>(&gce));
-
return 0;
}
void TwitterProto::SetChatStatus(int status)
{
- GCDEST gcd = { m_szModuleName };
- gcd.ptszID = const_cast<TCHAR*>(m_tszUserName);
- gcd.iType = GC_EVENT_CONTROL;
-
- GCEVENT gce = {sizeof(gce)};
- gce.dwFlags = GC_TCHAR;
- gce.pDest = &gcd;
+ GCDEST gcd = { m_szModuleName, (TCHAR*)m_tszUserName, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
if(status == ID_STATUS_ONLINE)
{
|