summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/yahoo/yahooverifyaccount.cpp
blob: cfb3ede6a9323a7c0f1261b4010d01c62075937c (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
/*
    yahooverifyaccount.cpp - UI Page for Verifying a locked account

    Copyright (c) 2005 by André Duffeck          <andre.duffeck@kdemail.net>

    *************************************************************************
    *                                                                       *
    * 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.                                   *
    *                                                                       *
    *************************************************************************
*/

// QT Includes
#include <qlayout.h>
#include <qfile.h>
#include <qlabel.h>

// KDE Includes
#include <kdebug.h>
#include <klineedit.h>
#include <ktempfile.h>
#include <klocale.h>
#include <kio/global.h>
#include <kio/job.h>
#include <kio/jobclasses.h>
#include <kstandarddirs.h>

// Kopete Includes
#include <yahooverifyaccountbase.h>
#include <kopeteaccount.h>

// Local Includes
#include "yahooverifyaccountbase.h"
#include "yahooverifyaccount.h"
#include "yahooaccount.h"

YahooVerifyAccount::YahooVerifyAccount(Kopete::Account *account, QWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n("Account Verification - Yahoo"), Cancel|Apply,
              Apply, true )
{
	mTheAccount = account;	
	mTheDialog = new YahooVerifyAccountBase( this );
	mTheDialog->mPicture->hide();
	setMainWidget( mTheDialog );
	setEscapeButton( Cancel );
}

// Destructor
YahooVerifyAccount::~YahooVerifyAccount()
{
	kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
}

void YahooVerifyAccount::setUrl( KURL url )
{
	mFile = new KTempFile( locateLocal( "tmp", url.fileName() ) );
	mFile->setAutoDelete( true );
	KIO::TransferJob *transfer = KIO::get( url, false, false );
	connect( transfer, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotComplete( KIO::Job* ) ) );
	connect( transfer, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) );
}

void YahooVerifyAccount::slotData( KIO::Job */*job*/, const QByteArray& data )
{

	kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;

	mFile->file()->writeBlock( data.data() , data.size() );
}

void YahooVerifyAccount::slotComplete( KIO::Job */*job*/ )
{

	kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;
	mFile->file()->close();
	mTheDialog->mPicture->setPixmap( mFile->file()->name() );
	mTheDialog->mPicture->show();
}

bool YahooVerifyAccount::validateData()
{
	kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;

	return ( !mTheDialog->mWord->text().isEmpty() );
}

void YahooVerifyAccount::slotClose()
{
	QDialog::done(0);
}

void YahooVerifyAccount::slotApply()
{
	kdDebug(YAHOO_GEN_DEBUG) << k_funcinfo << endl;

	YahooAccount* myAccount = static_cast<YahooAccount*>(mTheAccount);
	myAccount->verifyAccount( mTheDialog->mWord->text() );
	QDialog::done(0);
}

#include "yahooverifyaccount.moc"

// vim: set noet ts=4 sts=4 sw=4: