summaryrefslogtreecommitdiff
path: root/protocols/Yahoo/src/user_info.cpp
blob: 0f020adbd7d4335ebefa1aebae770f3d6328529b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * $Id: proto.cpp 9802 2009-05-18 03:03:48Z gena01 $
 *
 * 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 "yahoo.h"

#include <m_options.h>
#include <m_skin.h>
#include <m_userinfo.h>

#include "resource.h"

#include <commctrl.h>

static INT_PTR CALLBACK YahooUserInfoDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam )
{
	switch ( msg ) {
	case WM_INITDIALOG:
		// lParam is hContact
		TranslateDialogDefault(hwndDlg );

		//SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadSkinnedIcon(SKINICON_OTHER_USERDETAILS));

		
		break;

	case WM_NOTIFY:
		if (( ( LPNMHDR )lParam )->idFrom == 0) {
			switch (( ( LPNMHDR )lParam )->code ) {
			case PSN_PARAMCHANGED:
				SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (( PSHNOTIFY* )lParam )->lParam );
				break;
			case PSN_INFOCHANGED:
				{
					CYahooProto* ppro = (CYahooProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);

					if (!ppro)
						break;

					char* szProto;
					MCONTACT hContact = (MCONTACT)((LPPSHNOTIFY)lParam)->lParam;

					if (hContact == NULL) {
						szProto = ppro->m_szModuleName;
					} else {
						szProto = GetContactProto(hContact);
					}

					if (!szProto)
						break;

					if (hContact) {
						DBVARIANT dbv;
						char z[128];
						
						if (ppro->getString( hContact,  YAHOO_LOGINID, &dbv) == 0) {
							strcpy(z, dbv.pszVal);
							db_free(&dbv);
						} else {
							strcpy(z, "???");
						}
						
						SetDlgItemTextA(hwndDlg, IDC_SEARCH_ID, z);
						
						if (ppro->getString( hContact,  "Transport", &dbv) == 0) {
							strcpy(z, dbv.pszVal);
							db_free(&dbv);
						} else {
							strcpy(z, "Yahoo");
						}
						
						SetDlgItemTextA(hwndDlg, IDC_SEARCH_PROTOCOL, z);
						
						if (ppro->getString( hContact,  "MirVer", &dbv) == 0) {
							strcpy(z, dbv.pszVal);
							db_free(&dbv);
						} else {
							strcpy(z, "???");
						}
						
						SetDlgItemTextA(hwndDlg, IDC_NFO_CLIENT, z);
						
					} else {
					}
				}
				break;
			}	
		}
		break;

	case WM_CLOSE:
		DestroyWindow(hwndDlg);
		break;

	case WM_DESTROY:
		
		break;
	}
	return FALSE;
}

/////////////////////////////////////////////////////////////////////////////////////////
// OnInfoInit - initializes user info option dialogs

int __cdecl CYahooProto::OnUserInfoInit( WPARAM wParam, LPARAM lParam )
{
	OPTIONSDIALOGPAGE odp = { sizeof(odp) };
	odp.hInstance = hInstance;
	odp.dwInitParam = (LPARAM)this;
	odp.flags = ODPF_TCHAR | ODPF_DONTTRANSLATE;

	MCONTACT hContact = (MCONTACT)lParam;
	if ( IsMyContact(hContact)) {
		odp.pfnDlgProc = YahooUserInfoDlgProc;
		odp.position = -1900000000;
		odp.pszTemplate = MAKEINTRESOURCEA( IDD_USER_INFO );
		odp.ptszTitle = m_tszUserName;
		UserInfo_AddPage(wParam, &odp);
	} 
	return 0;
}