summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src/ownerinfo.cpp
blob: 6a11db6a3340542f8a9fc5586d03ce12220805e7 (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
////////////////////////////////////////////////////////////////////////////////
// Gadu-Gadu Plugin for Miranda IM
//
// Copyright (c) 2003-2006 Adam Strzelecki <ono+miranda@java.pl>
//
// 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 "gg.h"

typedef struct
{
	uin_t uin;
	const char *email;
} GG_REMIND_PASS;

//////////////////////////////////////////////////////////
// remind password
//
void __cdecl GGPROTO::remindpasswordthread(void *param)
{
	// Connection handle
	struct gg_http *h;
	GG_REMIND_PASS *rp = (GG_REMIND_PASS *)param;
	GGTOKEN token;

	debugLogA("remindpasswordthread(): Started.");
	if (!rp || !rp->email || !rp->uin || !mir_strlen(rp->email))
	{
		free(rp);
#ifdef DEBUGMODE
		debugLogA("remindpasswordthread(): End. err1");
#endif
		return;
	}

	// Get token
	if (!gettoken(&token)){
#ifdef DEBUGMODE
		debugLogA("remindpasswordthread(): End. err2");
#endif
		return;
	}

	if (!(h = gg_remind_passwd3(rp->uin, rp->email, token.id, token.val, 0)))
	{
		wchar_t error[128];
		mir_snwprintf(error, TranslateT("Password could not be reminded because of error:\n\t%s (Error: %d)"), ws_strerror(errno), errno);
		MessageBox(NULL, error, m_tszUserName, MB_OK | MB_ICONSTOP);
		debugLogW(L"remindpasswordthread(): Password could not be reminded. errno=%d: %s", errno, ws_strerror(errno));
	}
	else
	{
		gg_pubdir_free(h);
		debugLogA("remindpasswordthread(): Password remind successful.");
		MessageBox(NULL, TranslateT("Password was sent to your e-mail."), m_tszUserName, MB_OK | MB_ICONINFORMATION);
	}

	free(rp);
#ifdef DEBUGMODE
	debugLogA("remindpasswordthread(): End.");
#endif
}

void GGPROTO::remindpassword(uin_t uin, const char *email)
{
	GG_REMIND_PASS *rp = (GG_REMIND_PASS*)malloc(sizeof(GG_REMIND_PASS));

	rp->uin = uin;
	rp->email = email;
#ifdef DEBUGMODE
	debugLogA("remindpassword(): ForkThreadEx 20 GGPROTO::remindpasswordthread");
#endif
	ForkThread(&GGPROTO::remindpasswordthread, rp);
}