2
yahooeditaccount.cpp - UI Page to edit a Yahoo account
4
Copyright (c) 2003 by Matt Rogers <mattrogers@sbcglobal.net>
5
Copyright (c) 2002 by Gav Wood <gav@kde.org>
7
Copyright (c) 2002 by the Kopete developers <kopete-devel@kde.org>
9
*************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
*************************************************************************
25
#include <QPushButton>
28
#include <QLatin1String>
33
#include <kmessagebox.h>
36
#include <kfiledialog.h>
37
#include <kpassworddialog.h>
39
#include <kstandarddirs.h>
40
#include <ktoolinvocation.h>
43
#include <addcontactpage.h>
44
#include <kopeteuiglobal.h>
45
#include <avatardialog.h>
48
#include "yahooaccount.h"
49
#include "yahoocontact.h"
50
#include "yahooeditaccount.h"
52
// Yahoo Add Contact page
53
YahooEditAccount::YahooEditAccount(YahooProtocol *protocol, Kopete::Account *theAccount, QWidget *parent): QWidget(parent), KopeteEditAccountWidget(theAccount)
56
kDebug(YAHOO_GEN_DEBUG) ;
58
theProtocol = protocol;
60
if(YahooAccount *acct = dynamic_cast<YahooAccount*>(account()))
61
{ mScreenName->setText(acct->accountId());
62
mScreenName->setReadOnly(true); //the accountId is Constant FIXME: remove soon!
63
mAutoConnect->setChecked(acct->excludeConnect());
64
mPasswordWidget->load( &acct->password() );
66
QString pagerServer = account()->configGroup()->readEntry("Server", "scsa.msg.yahoo.com");
67
int pagerPort = account()->configGroup()->readEntry("Port", 5050);
68
if( pagerServer != "scsa.msg.yahoo.com" || pagerPort != 5050 )
69
optionOverrideServer->setChecked( true );
71
optionOverrideServer->setChecked( false );
72
editServerAddress->setText( pagerServer );
73
sbxServerPort->setValue( pagerPort );
75
QString iconUrl = account()->configGroup()->readEntry("pictureUrl", "");
76
bool sendPicture = account()->configGroup()->readEntry("sendPicture", false);
77
optionSendBuddyIcon->setChecked( sendPicture );
78
buttonSelectPicture->setEnabled( sendPicture );
79
connect( optionSendBuddyIcon, SIGNAL(toggled(bool)), buttonSelectPicture, SLOT(setEnabled(bool)) );
80
m_photoPath = iconUrl;
81
if( !iconUrl.isEmpty() )
82
m_Picture->setPixmap( iconUrl );
86
QObject::connect(buttonRegister, SIGNAL(clicked()), this, SLOT(slotOpenRegister()));
87
QObject::connect(buttonSelectPicture, SIGNAL(clicked()), this, SLOT(slotSelectPicture()));
89
optionSendBuddyIcon->setEnabled( account() );
91
/* Set tab order to password custom widget correctly */
92
QWidget::setTabOrder( mScreenName, mPasswordWidget->mRemembered );
93
QWidget::setTabOrder( mPasswordWidget->mRemembered, mPasswordWidget->mPassword );
94
QWidget::setTabOrder( mPasswordWidget->mPassword, mAutoConnect );
99
bool YahooEditAccount::validateData()
101
kDebug(YAHOO_GEN_DEBUG) ;
103
if(mScreenName->text().isEmpty())
104
{ KMessageBox::queuedMessageBox(this, KMessageBox::Sorry,
105
i18n("<qt>You must enter a valid screen name.</qt>"), i18n("Yahoo"));
108
if(!mPasswordWidget->validate())
109
{ KMessageBox::queuedMessageBox(this, KMessageBox::Sorry,
110
i18n("<qt>You must enter a valid password.</qt>"), i18n("Yahoo"));
116
Kopete::Account *YahooEditAccount::apply()
118
kDebug(YAHOO_GEN_DEBUG) ;
121
setAccount( new YahooAccount( theProtocol, mScreenName->text().toLower() ) );
123
YahooAccount *yahooAccount = static_cast<YahooAccount *>( account() );
125
yahooAccount->setExcludeConnect( mAutoConnect->isChecked() );
127
mPasswordWidget->save( &yahooAccount->password() );
129
if ( optionOverrideServer->isChecked() )
131
yahooAccount->setServer( editServerAddress->text().trimmed() );
132
yahooAccount->setPort( sbxServerPort->value() );
136
yahooAccount->setServer( "scsa.msg.yahoo.com" );
137
yahooAccount->setPort( 5050 );
140
account()->configGroup()->writeEntry("pictureUrl", m_photoPath );
141
account()->configGroup()->writeEntry("sendPicture", optionSendBuddyIcon->isChecked() );
142
if ( optionSendBuddyIcon->isChecked() )
144
yahooAccount->setBuddyIcon( m_photoPath );
148
yahooAccount->setBuddyIcon( KUrl() );
154
void YahooEditAccount::slotOpenRegister()
156
KToolInvocation::invokeBrowser( QLatin1String("http://edit.yahoo.com/config/eval_register?new=1") );
159
void YahooEditAccount::slotSelectPicture()
161
QString file = Kopete::UI::AvatarDialog::getAvatar( this, m_photoPath );
167
m_Picture->setPixmap( pix );
171
KMessageBox::queuedMessageBox( this, KMessageBox::Sorry, i18n( "<qt>The selected buddy icon could not be opened. <br />Please set a new buddy icon.</qt>" ), i18n( "Yahoo Plugin" ) );
176
#include "yahooeditaccount.moc"
178
// vim: set noet ts=4 sts=4 sw=4: