diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2014-04-15 08:46:04 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2014-04-15 08:46:04 +0000 |
commit | c015ec458520935c407aa1b2ce1d004c5c5c8a61 (patch) | |
tree | 9c77a0b9d3368731d08468105f52dcb2726c6d3f /protocols/ICQCorp/src/user.cpp | |
parent | bd7e07aa0bfb4fecdd09d0a48eabcb6899dd0601 (diff) |
ICQCorp adopted - needs Unicode fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@8980 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/ICQCorp/src/user.cpp')
-rw-r--r-- | protocols/ICQCorp/src/user.cpp | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/protocols/ICQCorp/src/user.cpp b/protocols/ICQCorp/src/user.cpp new file mode 100644 index 0000000000..c2274c7d26 --- /dev/null +++ b/protocols/ICQCorp/src/user.cpp @@ -0,0 +1,160 @@ +/*
+ ICQ Corporate protocol plugin for Miranda IM.
+ Copyright (C) 2003-2005 Eugene Tarasenko <zlyden13@inbox.ru>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "corp.h"
+
+std::vector <ICQUser *> icqUsers;
+
+///////////////////////////////////////////////////////////////////////////////
+
+ICQUser::ICQUser() :
+ socket(WM_NETEVENT_USER)
+{
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ICQUser::setStatus(unsigned short newStatus)
+{
+ if (statusVal == newStatus) return;
+
+ statusVal = newStatus;
+ db_set_w(hContact, protoName, "Status", newStatus);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ICQUser::setInfo(char *name, unsigned int data)
+{
+ if (data && data != 0xFFFFFFFF) db_set_dw(hContact, protoName, name, data);
+ else db_unset(hContact, protoName, name);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ICQUser::setInfo(char *name, unsigned short data)
+{
+ if (data && data != 0xFFFF) db_set_w(hContact, protoName, name, data);
+ else db_unset(hContact, protoName, name);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ICQUser::setInfo(char *name, unsigned char data)
+{
+ if (data && data != 0xFF) db_set_b(hContact, protoName, name, data);
+ else db_unset(hContact, protoName, name);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ICQUser::setInfo(char *name, char *data)
+{
+ if (data[0]) db_set_s(hContact, protoName, name, data);
+ else db_unset(hContact, protoName, name);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static char *iptoa(unsigned int ip)
+{
+ struct in_addr addr;
+
+ addr.S_un.S_addr = htonl(ip);
+ return inet_ntoa(addr);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static void setTextValue(HWND hWnd, int id, char *value)
+{
+ bool unspecified = value == NULL;
+
+ EnableWindow(GetDlgItem(hWnd, id), !unspecified);
+ SetDlgItemText(hWnd, id, unspecified ? Translate("<not specified>") : value);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+static BOOL CALLBACK icqUserInfoDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ LPNMHDR hdr;
+
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hWnd);
+ return TRUE;
+
+ case WM_NOTIFY:
+ hdr = (LPNMHDR)lParam;
+ if (hdr->idFrom == 0 && hdr->code == PSN_INFOCHANGED)
+ {
+ char buffer[64];
+ unsigned long ip, port;
+ MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;
+
+ _itoa(db_get_dw(hContact, protoName, "UIN", 0), buffer, 10);
+ setTextValue(hWnd, IDC_INFO_UIN, buffer);
+
+ ip = db_get_dw(hContact, protoName, "IP", 0);
+ setTextValue(hWnd, IDC_INFO_IP, ip ? iptoa(ip) : NULL);
+
+ ip = db_get_dw(hContact, protoName, "RealIP", 0);
+ setTextValue(hWnd, IDC_INFO_REALIP, ip ? iptoa(ip) : NULL);
+
+ port = db_get_w(hContact, protoName, "Port", 0);
+ _itoa(port, buffer, 10);
+ setTextValue(hWnd, IDC_INFO_PORT, port ? buffer : NULL);
+
+ setTextValue(hWnd, IDC_INFO_VERSION, NULL);
+ setTextValue(hWnd, IDC_INFO_MIRVER, NULL);
+ setTextValue(hWnd, IDC_INFO_PING, NULL);
+ }
+ break;
+
+ case WM_COMMAND:
+ if (LOWORD(wParam) == IDCANCEL) SendMessage(GetParent(hWnd), msg, wParam, lParam);
+ break;
+ }
+ return FALSE;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+int icqUserInfoInitialise(WPARAM wParam, LPARAM lParam)
+{
+ OPTIONSDIALOGPAGE odp = { 0 };
+ char *proto;
+
+ proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, lParam, 0);
+ if ((proto == NULL || strcmp(proto, protoName)) && lParam) return 0;
+
+ odp.cbSize = sizeof(odp);
+ odp.position = -1900000000;
+ odp.pszTitle = Translate(protoName);
+ odp.pfnDlgProc = (DLGPROC)icqUserInfoDlgProc;
+ odp.pszTemplate = MAKEINTRESOURCE(IDD_INFO_ICQCORP);
+ odp.hInstance = hInstance;
+ Options_AddPage(wParam, &odp);
+
+ return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
|