1 /* This file is part of the KDE project
2 Copyright (C) 2005 Michal Vaner <michal.vaner@kdemail.net>
3 Copyright (C) 2008-2009 Pali Rohár <pali.rohar@gmail.com>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
22 #include "skypeeditaccount.h"
23 #include "skypeprotocol.h"
24 #include "skypeaccount.h"
26 #include <qlineedit.h>
28 #include <kmessagebox.h>
30 #include <kopeteaccountmanager.h>
31 #include <qcheckbox.h>
32 #include <qlineedit.h>
34 #include <qbuttongroup.h>
37 class SkypeEditAccountPrivate
{
40 SkypeProtocol
*protocol
;
42 SkypeAccount
*account
;
45 skypeEditAccount::skypeEditAccount(SkypeProtocol
*protocol
, Kopete::Account
*account
, QWidget
*parent
) : QWidget(parent
), KopeteEditAccountWidget(account
) {
46 kDebug() << k_funcinfo
<< endl
;//some debug info
48 QVBoxLayout
*layout
= new QVBoxLayout( this );
49 QWidget
*w
= new QWidget( this );
50 widget
= new Ui::SkypeEditAccountBase();
52 layout
->addWidget( w
);
54 d
= new SkypeEditAccountPrivate();//the d pointer
55 d
->protocol
= protocol
;//I may need the protocol later
57 d
->account
= (SkypeAccount
*) account
;//save the account
59 //Now, check weather it is existing account or just an old one to modify
60 if (account
) {//it is old one
61 widget
->excludeCheck
->setChecked(account
->excludeConnect());//Check, weather it should be excluded
62 //LaunchGroup->setButton(d->account->launchType);//set the launch type
63 widget
->AuthorCheck
->setChecked(!d
->account
->author
.isEmpty());//set the check box that allows you to change authorization
64 if (widget
->AuthorCheck
->isChecked())
65 widget
->AuthorEdit
->setText(d
->account
->author
);//set the name
66 widget
->MarkCheck
->setChecked(d
->account
->getMarkRead());//set the get read mode
67 widget
->HitchCheck
->setChecked(d
->account
->getHitchHike());
68 widget
->ScanCheck
->setChecked(d
->account
->getScanForUnread());
69 widget
->CallCheck
->setChecked(d
->account
->getCallControl());
70 widget
->PingsCheck
->setChecked(d
->account
->getPings());
71 //BusGroup->setButton(d->account->getBus());
72 widget
->LaunchSpin
->setValue(d
->account
->getLaunchTimeout());
73 widget
->CommandEdit
->setText(d
->account
->getSkypeCommand());
74 widget
->WaitSpin
->setValue(d
->account
->getWaitBeforeConnect());
75 if (d
->account
->closeCallWindowTimeout()) {
76 widget
->AutoCloseCallCheck
->setChecked(true);
77 widget
->CloseTimeoutSpin
->setValue(d
->account
->closeCallWindowTimeout());
78 } else widget
->AutoCloseCallCheck
->setChecked(false);
79 widget
->LeaveCheck
->setChecked(d
->account
->leaveOnExit());
80 const QString
&startCallCommand
= d
->account
->startCallCommand();
81 widget
->StartCallCommandCheck
->setChecked(!startCallCommand
.isEmpty());
82 widget
->StartCallCommandEdit
->setText(startCallCommand
);
83 widget
->WaitForStartCallCommandCheck
->setChecked(d
->account
->waitForStartCallCommand());
84 const QString
&endCallCommand
= d
->account
->endCallCommand();
85 widget
->EndCallCommandCheck
->setChecked(!endCallCommand
.isEmpty());
86 widget
->EndCallCommandEdit
->setText(endCallCommand
);
87 widget
->OnlyLastCallCommandCheck
->setChecked(d
->account
->endCallCommandOnlyLast());
88 const QString
&incomingCommand
= d
->account
->incomingCommand();
89 widget
->IncomingCommandCheck
->setChecked(!incomingCommand
.isEmpty());
90 widget
->IncomingCommandEdit
->setText(incomingCommand
);
92 //KMessageBox::information(this, i18n("Please note that this version of Skype plugin is a development version and it is probable it will cause more problems than solve. You have been warned"), i18n("Version info")); - I hope it is not needed any more
96 skypeEditAccount::~skypeEditAccount() {
97 kDebug() << k_funcinfo
<< endl
;//some debug info
103 bool skypeEditAccount::validateData() {
104 kDebug() << k_funcinfo
<< endl
;//some debug info
106 if (d
->protocol
->hasAccount() && (!account())) {//he wants to create some account witch name is already used
107 KMessageBox::sorry(this, i18n("You can have only one skype account"), i18n("Wrong Information"));//Tell him to use something other
111 return true;//It seems OK
114 Kopete::Account
*skypeEditAccount::apply() {
115 kDebug() << k_funcinfo
<< endl
;//some debug info
117 //first, I need a pointer to that account
118 if (!account()) //it does not exist
119 setAccount(new SkypeAccount(d
->protocol
, "Skype" ));//create a new one
120 SkypeAccount
*skype
= static_cast<SkypeAccount
*>(account());//get the account
123 skype
->setExcludeConnect(widget
->excludeCheck
->isChecked());//Save the "exclude from connection" setup
124 skype
->launchType
= widget
->LaunchGroup
->selectedId();//get the type how to launch skype
125 if (widget
->AuthorCheck
->isChecked())
126 skype
->author
= widget
->AuthorEdit
->text();//put there what user wrote
128 skype
->author
= "";//nothing unusual
129 skype
->setHitchHike(widget
->HitchCheck
->isChecked());//save the hitch hike mode and activat ethe new value
130 skype
->setMarkRead(widget
->MarkCheck
->isChecked());//set the mark read messages mode and activate it
131 skype
->setScanForUnread(widget
->ScanCheck
->isChecked());
132 skype
->setCallControl(widget
->CallCheck
->isChecked());
133 skype
->setPings(widget
->PingsCheck
->isChecked());
134 skype
->setBus(widget
->BusGroup
->selectedId());
135 skype
->setLaunchTimeout(widget
->LaunchSpin
->value());
136 skype
->setSkypeCommand(widget
->CommandEdit
->text());
137 skype
->setWaitBeforeConnect(widget
->WaitSpin
->value());
138 skype
->setLeaveOnExit(widget
->LeaveCheck
->isChecked());
139 if (widget
->AutoCloseCallCheck
->isChecked()) {
140 skype
->setCloseWindowTimeout(widget
->CloseTimeoutSpin
->value());
142 skype
->setCloseWindowTimeout(0);
144 if (widget
->StartCallCommandCheck
->isChecked()) {
145 skype
->setStartCallCommand(widget
->StartCallCommandEdit
->text());
147 skype
->setStartCallCommand("");
149 skype
->setWaitForStartCallCommand(widget
->WaitForStartCallCommandCheck
->isChecked());
150 if (widget
->EndCallCommandCheck
->isChecked()) {
151 skype
->setEndCallCommand(widget
->EndCallCommandEdit
->text());
153 skype
->setEndCallCommand("");
155 if (widget
->IncomingCommandCheck
->isChecked()) {
156 skype
->setIncomingCommand(widget
->IncomingCommandEdit
->text());
158 skype
->setIncomingCommand("");
161 skype
->setEndCallCommandOnlyForLast(widget
->OnlyLastCallCommandCheck
->isChecked());
162 skype
->save();//save it to config
163 return skype
;//return the account
166 #include "skypeeditaccount.moc"