kitchensync

remotekonnectorconfig.cpp

00001 /*
00002     This file is part of KitchenSync.
00003 
00004     Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "remotekonnectorconfig.h"
00023 
00024 #include "remotekonnector.h"
00025 
00026 #include <libkcal/resourcelocal.h>
00027 
00028 #include <kconfig.h>
00029 #include <klocale.h>
00030 #include <kabc/resourcefile.h>
00031 #include <kmessagebox.h>
00032 #include <kinputdialog.h>
00033 #include <klineedit.h>
00034 
00035 #include <qlabel.h>
00036 #include <qlayout.h>
00037 #include <qpushbutton.h>
00038 
00039 using namespace KSync;
00040 
00041 RemoteKonnectorConfig::RemoteKonnectorConfig( QWidget *parent )
00042   : KRES::ConfigWidget( parent, 0 )
00043 {
00044   QBoxLayout *topLayout = new QVBoxLayout( this );
00045 
00046   QPushButton *button = new QPushButton( i18n("Standard Setup..."), this );
00047   topLayout->addWidget( button );
00048   connect( button, SIGNAL( clicked() ), SLOT( setupStandard() ) );
00049 
00050   topLayout->addWidget( new QLabel( i18n("Calendar file:"), this ) );
00051 
00052   mCalendarUrl = new KURLRequester( this );
00053   mCalendarUrl->setMode( KFile::File );
00054   topLayout->addWidget( mCalendarUrl );
00055 
00056   topLayout->addSpacing( 4 );
00057 
00058   topLayout->addWidget( new QLabel( i18n("Address book file:"), this ) );
00059 
00060   mAddressBookUrl = new KURLRequester( this );
00061   mAddressBookUrl->setMode( KFile::File );
00062   topLayout->addWidget( mAddressBookUrl );
00063 }
00064 
00065 RemoteKonnectorConfig::~RemoteKonnectorConfig()
00066 {
00067 }
00068 
00069 void RemoteKonnectorConfig::loadSettings( KRES::Resource *r )
00070 {
00071   RemoteKonnector *konnector = dynamic_cast<RemoteKonnector *>( r );
00072   if ( konnector ) {
00073     mCalendarUrl->setURL( konnector->calendarUrl() );
00074     mAddressBookUrl->setURL( konnector->addressBookUrl() );
00075   }
00076 }
00077 
00078 void RemoteKonnectorConfig::saveSettings( KRES::Resource *r )
00079 {
00080   RemoteKonnector *konnector = dynamic_cast<RemoteKonnector *>( r );
00081   if ( konnector ) {
00082     konnector->setCalendarUrl( mCalendarUrl->url() );
00083     konnector->setAddressBookUrl( mAddressBookUrl->url() );
00084   }
00085 }
00086 
00087 void RemoteKonnectorConfig::setupStandard()
00088 {
00089   bool ok = false;
00090 
00091   QString hostname = KInputDialog::getText( i18n( "Remote Host" ), i18n( "Enter remote host name:" ),
00092                                             QString::null, &ok, this );
00093 
00094   if ( hostname.isEmpty() || !ok )
00095     return;
00096 
00097   QString username = KInputDialog::getText( i18n( "Remote User" ), i18n( "Enter remote user name:" ),
00098                                             QString::null, &ok, this );
00099 
00100   if ( username.isEmpty() || !ok )
00101     return;
00102 
00103   QString urlBase = "fish://" + hostname + "/~" + username + "/";
00104   mCalendarUrl->setURL( urlBase + ".kde/share/apps/korganizer/std.ics" );
00105   mAddressBookUrl->setURL( urlBase + ".kde/share/apps/kabc/std.vcf" );
00106 }
00107 
00108 #include "remotekonnectorconfig.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys