diff options
Diffstat (limited to 'tderesources/scalix/scalixadmin')
31 files changed, 2618 insertions, 0 deletions
diff --git a/tderesources/scalix/scalixadmin/CMakeLists.txt b/tderesources/scalix/scalixadmin/CMakeLists.txt new file mode 100644 index 000000000..f13d11a83 --- /dev/null +++ b/tderesources/scalix/scalixadmin/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### scalixadmin (executable) ################## + +tde_add_executable( scalixadmin AUTOMOC + SOURCES + main.cpp mainwindow.cpp passwordpage.cpp settings.cpp jobs.cpp + otherusermanager.cpp otheruserview.cpp otheruserpage.cpp ldapview.cpp + ldapdialog.cpp delegatemanager.cpp delegateview.cpp delegatepage.cpp + delegatedialog.cpp outofofficepage.cpp + LINK kabc-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/tderesources/scalix/scalixadmin/Makefile.am b/tderesources/scalix/scalixadmin/Makefile.am new file mode 100644 index 000000000..05d29b985 --- /dev/null +++ b/tderesources/scalix/scalixadmin/Makefile.am @@ -0,0 +1,15 @@ +bin_PROGRAMS = scalixadmin + +INCLUDES = $(all_includes) + +scalixadmin_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor +scalixadmin_LDADD = $(LIB_KABC) +scalixadmin_SOURCES = main.cpp mainwindow.cpp passwordpage.cpp settings.cpp jobs.cpp \ + otherusermanager.cpp otheruserview.cpp otheruserpage.cpp ldapview.cpp ldapdialog.cpp \ + delegatemanager.cpp delegateview.cpp delegatepage.cpp delegatedialog.cpp \ + outofofficepage.cpp + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/scalixadmin.pot diff --git a/tderesources/scalix/scalixadmin/delegatedialog.cpp b/tderesources/scalix/scalixadmin/delegatedialog.cpp new file mode 100644 index 000000000..661f57430 --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegatedialog.cpp @@ -0,0 +1,105 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqcheckbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqtoolbutton.h> + +#include <klocale.h> + +#include "jobs.h" +#include "ldapdialog.h" + +#include "delegatedialog.h" + +DelegateDialog::DelegateDialog( TQWidget *parent ) + : KDialogBase( parent, "", true, "", Ok | Cancel, Ok, true ) +{ + TQWidget *page = new TQWidget( this ); + TQGridLayout *layout = new TQGridLayout( page, 5, 3, 11, 6 ); + + TQLabel *label = new TQLabel( i18n( "User:" ), page ); + layout->addWidget( label, 0, 0 ); + + mEmail = new TQLineEdit( page ); + layout->addWidget( mEmail, 0, 1 ); + + TQToolButton *emailSelector = new TQToolButton( page ); + emailSelector->setUsesTextLabel( true ); + emailSelector->setTextLabel( i18n( "..." ) ); + layout->addWidget( emailSelector, 0, 2 ); + + TQValueList<Scalix::DelegateTypes> types; + types << Scalix::SendOnBehalfOf; + types << Scalix::SeePrivate; + types << Scalix::GetMeetings; + types << Scalix::InsteadOfMe; + + int row = 1; + for ( uint i = 0; i < types.count(); ++i ) { + TQCheckBox *box = new TQCheckBox( Scalix::Delegate::rightsAsString( types[ i ] ), page ); + layout->addMultiCellWidget( box, row, row, 1, 2 ); + + mRights.insert( types[ i ], box ); + row++; + } + + connect( emailSelector, TQT_SIGNAL( clicked() ), TQT_SLOT( selectEmail() ) ); + + setMainWidget( page ); +} + +void DelegateDialog::setDelegate( const Scalix::Delegate &delegate ) +{ + mEmail->setText( delegate.email() ); + + TQMap<int, TQCheckBox*>::Iterator it; + for ( it = mRights.begin(); it != mRights.end(); ++it ) + it.data()->setChecked( delegate.rights() & it.key() ); +} + +Scalix::Delegate DelegateDialog::delegate() const +{ + int rights = 0; + + TQMap<int, TQCheckBox*>::ConstIterator it; + for ( it = mRights.begin(); it != mRights.end(); ++it ) + if ( it.data()->isChecked() ) + rights |= it.key(); + + return Scalix::Delegate( mEmail->text(), rights ); +} + +void DelegateDialog::selectEmail() +{ + LdapDialog dlg( this ); + if ( !dlg.exec() ) + return; + + const TQString email = dlg.selectedUser(); + if ( email.isEmpty() ) + return; + + mEmail->setText( email ); +} + +#include "delegatedialog.moc" diff --git a/tderesources/scalix/scalixadmin/delegatedialog.h b/tderesources/scalix/scalixadmin/delegatedialog.h new file mode 100644 index 000000000..2f258113f --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegatedialog.h @@ -0,0 +1,54 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef DELEGATEDIALOG_H +#define DELEGATEDIALOG_H + +#include <tqmap.h> + +#include <kdialogbase.h> + +class TQCheckBox; +class TQLineEdit; + +namespace Scalix { +class Delegate; +} + +class DelegateDialog : public KDialogBase +{ + Q_OBJECT + + + public: + DelegateDialog( TQWidget *parent = 0 ); + + void setDelegate( const Scalix::Delegate &delegate ); + Scalix::Delegate delegate() const; + + private slots: + void selectEmail(); + + private: + TQLineEdit *mEmail; + TQMap<int, TQCheckBox*> mRights; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/delegatemanager.cpp b/tderesources/scalix/scalixadmin/delegatemanager.cpp new file mode 100644 index 000000000..686370d77 --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegatemanager.cpp @@ -0,0 +1,49 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "delegatemanager.h" + +DelegateManager::DelegateManager() +{ +} + +DelegateManager::~DelegateManager() +{ +} + +void DelegateManager::addDelegate( const Scalix::Delegate &delegate ) +{ + mDelegates.append( delegate ); + emit changed(); +} + +void DelegateManager::clear() +{ + mDelegates.clear(); + + emit changed(); +} + +Scalix::Delegate::List DelegateManager::delegates() const +{ + return mDelegates; +} + +#include "delegatemanager.moc" diff --git a/tderesources/scalix/scalixadmin/delegatemanager.h b/tderesources/scalix/scalixadmin/delegatemanager.h new file mode 100644 index 000000000..05b0262d8 --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegatemanager.h @@ -0,0 +1,50 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef DELEGATEMANAGER_H +#define DELEGATEMANAGER_H + +#include <tqobject.h> +#include <tqstringlist.h> + +#include "jobs.h" + +class DelegateManager : public TQObject +{ + Q_OBJECT + + + public: + DelegateManager(); + ~DelegateManager(); + + void addDelegate( const Scalix::Delegate &delegate ); + void clear(); + + Scalix::Delegate::List delegates() const; + + signals: + void changed(); + + private: + Scalix::Delegate::List mDelegates; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/delegatepage.cpp b/tderesources/scalix/scalixadmin/delegatepage.cpp new file mode 100644 index 000000000..169ff0853 --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegatepage.cpp @@ -0,0 +1,170 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqlayout.h> +#include <tqpushbutton.h> + +#include <kinputdialog.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include <unistd.h> + +#include "delegatedialog.h" +#include "delegateview.h" +#include "jobs.h" +#include "settings.h" + +#include "delegatepage.h" + +DelegatePage::DelegatePage( TQWidget *parent ) + : TQWidget( parent ) +{ + TQGridLayout *layout = new TQGridLayout( this, 2, 3, 11, 6 ); + + mView = new DelegateView( &mManager, this ); + layout->addMultiCellWidget( mView, 0, 0, 0, 2 ); + + mAddButton = new TQPushButton( i18n( "Add Delegate..." ), this ); + layout->addWidget( mAddButton, 1, 0 ); + + mEditButton = new TQPushButton( i18n( "Edit Delegate..." ), this ); + mEditButton->setEnabled( false ); + layout->addWidget( mEditButton, 1, 1 ); + + mRemoveButton = new TQPushButton( i18n( "Remove Delegate" ), this ); + mRemoveButton->setEnabled( false ); + layout->addWidget( mRemoveButton, 1, 2 ); + + connect( mView, TQT_SIGNAL( selectionChanged() ), TQT_SLOT( selectionChanged() ) ); + connect( mAddButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addDelegate() ) ); + connect( mEditButton, TQT_SIGNAL( clicked() ), TQT_SLOT( editDelegate() ) ); + connect( mRemoveButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeDelegate() ) ); + + loadAllDelegates(); +} + +DelegatePage::~DelegatePage() +{ +} + +void DelegatePage::loadAllDelegates() +{ + Scalix::GetDelegatesJob *job = Scalix::getDelegates( Settings::self()->globalSlave(), + Settings::self()->accountUrl() ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( allDelegates( TDEIO::Job* ) ) ); +} + +void DelegatePage::addDelegate() +{ + DelegateDialog dlg( this ); + dlg.setCaption( i18n( "Add Delegate" ) ); + + if ( !dlg.exec() ) + return; + + const Scalix::Delegate delegate = dlg.delegate(); + + if ( !delegate.isValid() ) + return; + + Scalix::SetDelegateJob *job = Scalix::setDelegate( Settings::self()->globalSlave(), + Settings::self()->accountUrl(), + delegate.email(), delegate.rights() ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( delegateAdded( TDEIO::Job* ) ) ); +} + +void DelegatePage::editDelegate() +{ + const Scalix::Delegate oldDelegate = mView->selectedDelegate(); + if ( !oldDelegate.isValid() ) + return; + + DelegateDialog dlg( this ); + dlg.setCaption( i18n( "Edit Delegate" ) ); + + dlg.setDelegate( oldDelegate ); + + if ( !dlg.exec() ) + return; + + const Scalix::Delegate delegate = dlg.delegate(); + + if ( !delegate.isValid() ) + return; + + Scalix::SetDelegateJob *job = Scalix::setDelegate( Settings::self()->globalSlave(), + Settings::self()->accountUrl(), + delegate.email(), delegate.rights() ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( delegateAdded( TDEIO::Job* ) ) ); +} + +void DelegatePage::removeDelegate() +{ + const Scalix::Delegate delegate = mView->selectedDelegate(); + if ( !delegate.isValid() ) + return; + + Scalix::DeleteDelegateJob *job = Scalix::deleteDelegate( Settings::self()->globalSlave(), + Settings::self()->accountUrl(), delegate.email() ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( delegateRemoved( TDEIO::Job* ) ) ); +} + +void DelegatePage::allDelegates( TDEIO::Job *job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); + + Scalix::GetDelegatesJob *delegateJob = static_cast<Scalix::GetDelegatesJob*>( job ); + + mManager.clear(); + + const Scalix::Delegate::List delegates = delegateJob->delegates(); + for ( uint i = 0; i < delegates.count(); ++i ) + mManager.addDelegate( delegates[ i ] ); + + selectionChanged(); +} + +void DelegatePage::delegateAdded( TDEIO::Job *job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); + else + loadAllDelegates(); // update the GUI +} + +void DelegatePage::delegateRemoved( TDEIO::Job *job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); + else + loadAllDelegates(); // update the GUI +} + +void DelegatePage::selectionChanged() +{ + bool state = ( mView->selectedItem() != 0 ); + + mEditButton->setEnabled( state ); + mRemoveButton->setEnabled( state ); +} + +#include "delegatepage.moc" diff --git a/tderesources/scalix/scalixadmin/delegatepage.h b/tderesources/scalix/scalixadmin/delegatepage.h new file mode 100644 index 000000000..0523effee --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegatepage.h @@ -0,0 +1,61 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef DELEGATEPAGE_H +#define DELEGATEPAGE_H + +#include <tqwidget.h> + +#include "delegatemanager.h" + +class TQPushButton; +class DelegateView; + +class DelegatePage : public TQWidget +{ + Q_OBJECT + + + public: + DelegatePage( TQWidget *parent = 0 ); + ~DelegatePage(); + + private slots: + void loadAllDelegates(); + void addDelegate(); + void editDelegate(); + void removeDelegate(); + + void delegateAdded( TDEIO::Job* ); + void delegateRemoved( TDEIO::Job* ); + void allDelegates( TDEIO::Job* ); + + void selectionChanged(); + + private: + TQPushButton *mAddButton; + TQPushButton *mEditButton; + TQPushButton *mRemoveButton; + + DelegateManager mManager; + DelegateView *mView; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/delegateview.cpp b/tderesources/scalix/scalixadmin/delegateview.cpp new file mode 100644 index 000000000..1031f460e --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegateview.cpp @@ -0,0 +1,74 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <klocale.h> + +#include "delegatemanager.h" + +#include "delegateview.h" + +class DelegateItem : public TQListViewItem +{ + public: + DelegateItem( TQListView *parent, const Scalix::Delegate &delegate ) + : TQListViewItem( parent ), mDelegate( delegate ) + { + setText( 0, mDelegate.email() ); + setText( 1, Scalix::Delegate::rightsAsString( mDelegate.rights() ) ); + } + + Scalix::Delegate delegate() const { return mDelegate; } + + private: + Scalix::Delegate mDelegate; +}; + +DelegateView::DelegateView( DelegateManager *manager, TQWidget *parent ) + : KListView( parent ), mManager( manager ) +{ + addColumn( i18n( "Delegate" ) ); + addColumn( i18n( "Rights" ) ); + setFullWidth( true ); + setAllColumnsShowFocus( true ); + + connect( mManager, TQT_SIGNAL( changed() ), TQT_SLOT( delegateChanged() ) ); + + delegateChanged(); +} + +Scalix::Delegate DelegateView::selectedDelegate() const +{ + DelegateItem *item = dynamic_cast<DelegateItem*>( selectedItem() ); + if ( item ) + return item->delegate(); + + return Scalix::Delegate(); +} + +void DelegateView::delegateChanged() +{ + clear(); + + const Scalix::Delegate::List delegates = mManager->delegates(); + for ( uint i = 0; i < delegates.count(); ++i ) + new DelegateItem( this, delegates[ i ] ); +} + +#include "delegateview.moc" diff --git a/tderesources/scalix/scalixadmin/delegateview.h b/tderesources/scalix/scalixadmin/delegateview.h new file mode 100644 index 000000000..5dfa379f7 --- /dev/null +++ b/tderesources/scalix/scalixadmin/delegateview.h @@ -0,0 +1,49 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef DELEGATEVIEW_H +#define DELEGATEVIEW_H + +#include <klistview.h> + +namespace Scalix { +class Delegate; +} + +class DelegateManager; + +class DelegateView : public KListView +{ + Q_OBJECT + + + public: + DelegateView( DelegateManager *manager, TQWidget *parent = 0 ); + + Scalix::Delegate selectedDelegate() const; + + private slots: + void delegateChanged(); + + private: + DelegateManager *mManager; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/jobs.cpp b/tderesources/scalix/scalixadmin/jobs.cpp new file mode 100644 index 000000000..49b0a8fe5 --- /dev/null +++ b/tderesources/scalix/scalixadmin/jobs.cpp @@ -0,0 +1,306 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kio/scheduler.h> +#include <klocale.h> + +#include "jobs.h" + +using namespace Scalix; + +Delegate::Delegate() + : mRights( -1 ) +{ +} + +Delegate::Delegate( const TQString &email, int rights ) + : mEmail( email ), mRights( rights ) +{ +} + +bool Delegate::isValid() const +{ + return ( !mEmail.isEmpty() && mRights != -1 ); +} + +TQString Delegate::email() const +{ + return mEmail; +} + +int Delegate::rights() const +{ + return mRights; +} + +TQString Delegate::rightsAsString( int rights ) +{ + TQStringList rightNames; + + if ( rights & SendOnBehalfOf ) + rightNames.append( i18n( "Send on behalf of" ) ); + if ( rights & SeePrivate ) + rightNames.append( i18n( "See private" ) ); + if ( rights & GetMeetings ) + rightNames.append( i18n( "Get meetings" ) ); + if ( rights & InsteadOfMe ) + rightNames.append( i18n( "Instead of me" ) ); + + return rightNames.join( ", " ); +} + + +SetPasswordJob* Scalix::setPassword( TDEIO::Slave* slave, const KURL& url, + const TQString &oldPassword, const TQString& newPassword ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-SCALIX-PASSWORD" ) << TQString( "%1 %2" ).arg( oldPassword ).arg( newPassword ); + + SetPasswordJob* job = new SetPasswordJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +SetDelegateJob* Scalix::setDelegate( TDEIO::Slave* slave, const KURL& url, const TQString& email, int params ) +{ + TQStringList types; + if ( params & SendOnBehalfOf ) + types.append( "SOBO" ); + if ( params & SeePrivate ) + types.append( "SEEPRIVATE" ); + if ( params & GetMeetings ) + types.append( "GETMEETINGS" ); + if ( params & InsteadOfMe ) + types.append( "INSTEADOFME" ); + + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-SET-DELEGATE" ) << TQString( "%1 %2" ).arg( email ).arg( types.join( " " ) ); + + SetDelegateJob* job = new SetDelegateJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +DeleteDelegateJob* Scalix::deleteDelegate( TDEIO::Slave* slave, const KURL& url, const TQString& email ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-DELETE-DELEGATE" ) << email; + + DeleteDelegateJob* job = new DeleteDelegateJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +GetDelegatesJob* Scalix::getDelegates( TDEIO::Slave* slave, const KURL& url ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' << TQString( "X-GET-DELEGATES" ) << TQString(); + + GetDelegatesJob* job = new GetDelegatesJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +AddOtherUserJob* Scalix::addOtherUser( TDEIO::Slave* slave, const KURL& url, const TQString& email ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-ADD-OTHER-USER" ) << email; + + AddOtherUserJob* job = new AddOtherUserJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +DeleteOtherUserJob* Scalix::deleteOtherUser( TDEIO::Slave* slave, const KURL& url, const TQString& email ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-DELETE-OTHER-USER" ) << email; + + DeleteOtherUserJob* job = new DeleteOtherUserJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +GetOtherUsersJob* Scalix::getOtherUsers( TDEIO::Slave* slave, const KURL& url ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-GET-OTHER-USERS" ) << TQString(); + + GetOtherUsersJob* job = new GetOtherUsersJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +SetOutOfOfficeJob* Scalix::setOutOfOffice( TDEIO::Slave* slave, const KURL& url, bool enabled, const TQString& msg ) +{ + const TQString argument = msg; + const TQString command = TQString( "X-SET-OUT-OF-OFFICE %1 %2 {%3}" ).arg( enabled ? "ENABLED" : "DISABLED" ) + .arg( "UTF-8" ) + .arg( msg.utf8().length() ); + + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int) 'X' << (int)'E' << command << argument; + + SetOutOfOfficeJob* job = new SetOutOfOfficeJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +GetOutOfOfficeJob* Scalix::getOutOfOffice( TDEIO::Slave* slave, const KURL& url ) +{ + TQByteArray packedArgs; + TQDataStream stream( packedArgs, IO_WriteOnly ); + stream << (int)'X' << (int)'N' + << TQString( "X-GET-OUT-OF-OFFICE" ) << TQString(); + + GetOutOfOfficeJob* job = new GetOutOfOfficeJob( url, packedArgs, false ); + TDEIO::Scheduler::assignJobToSlave( slave, job ); + return job; +} + +SetPasswordJob::SetPasswordJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ +} + +SetDelegateJob::SetDelegateJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ +} + +DeleteDelegateJob::DeleteDelegateJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ +} + +GetDelegatesJob::GetDelegatesJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ + connect( this, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ), + this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) ); +} + +Delegate::List GetDelegatesJob::delegates() const +{ + return mDelegates; +} + +void GetDelegatesJob::slotInfoMessage( TDEIO::Job*, const TQString &data ) +{ + /** + * The passed data have the following form: + * + * "user1@host.com:right1,right2,right4 user2@host.com:right3,right5" + */ + TQStringList delegates = TQStringList::split( ' ', data ); + for ( uint i = 0; i < delegates.count(); ++i ) { + TQStringList delegate = TQStringList::split( ':', delegates[ i ] ); + + const TQString email = delegate[ 0 ]; + int rights = 0; + + TQStringList rightsList = TQStringList::split( ',', delegate[ 1 ] ); + for ( uint j = 0; j < rightsList.count(); ++j ) { + if ( rightsList[ j ] == "SOBO" ) + rights |= SendOnBehalfOf; + else if ( rightsList[ j ] == "SEEPRIVATE" ) + rights |= SeePrivate; + else if ( rightsList[ j ] == "GETMEETINGS" ) + rights |= GetMeetings; + else if ( rightsList[ j ] == "INSTEADOFME" ) + rights |= InsteadOfMe; + } + + mDelegates.append( Delegate( email, rights ) ); + } +} + +AddOtherUserJob::AddOtherUserJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ +} + +DeleteOtherUserJob::DeleteOtherUserJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ +} + +GetOtherUsersJob::GetOtherUsersJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ + connect( this, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ), + this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) ); +} + +TQStringList GetOtherUsersJob::otherUsers() const +{ + return mOtherUsers; +} + +void GetOtherUsersJob::slotInfoMessage( TDEIO::Job*, const TQString &data ) +{ + mOtherUsers = TQStringList::split( ' ', data ); +} + +SetOutOfOfficeJob::SetOutOfOfficeJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ +} + +GetOutOfOfficeJob::GetOutOfOfficeJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ) + : TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo ) +{ + connect( this, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ), + this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) ); +} + +bool GetOutOfOfficeJob::enabled() const +{ + return mEnabled; +} + +TQString GetOutOfOfficeJob::message() const +{ + return mMessage; +} + +void GetOutOfOfficeJob::slotInfoMessage( TDEIO::Job*, const TQString &data ) +{ + const TQStringList fields = TQStringList::split( '^', data ); + + mEnabled = ( fields[ 0 ] == "ENABLED" ); + mMessage = fields[ 1 ]; +} + +#include "jobs.moc" diff --git a/tderesources/scalix/scalixadmin/jobs.h b/tderesources/scalix/scalixadmin/jobs.h new file mode 100644 index 000000000..0c73fb507 --- /dev/null +++ b/tderesources/scalix/scalixadmin/jobs.h @@ -0,0 +1,205 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kio/job.h> + +#ifndef JOBS_H +#define JOBS_H + +namespace Scalix { + + enum DelegateTypes + { + SendOnBehalfOf = 1, + SeePrivate = 2, + GetMeetings = 4, + InsteadOfMe = 8 + }; + + class SetPasswordJob; + class SetDelegateJob; + class DeleteDelegateJob; + class GetDelegatesJob; + class AddOtherUserJob; + class DeleteOtherUserJob; + class GetOtherUsersJob; + class SetOutOfOfficeJob; + class GetOutOfOfficeJob; + + class Delegate + { + public: + typedef TQValueList<Delegate> List; + + Delegate(); + Delegate( const TQString &email, int rights ); + + bool isValid() const; + + TQString email() const; + int rights() const; + + static TQString rightsAsString( int rights ); + + private: + TQString mEmail; + int mRights; + }; + + /** + * Sets/Changes the password of the user encoded in @p url. + */ + SetPasswordJob* setPassword( TDEIO::Slave* slave, const KURL& url, const TQString& oldPassword, const TQString& newPassword ); + + /** + * Adds a delegate represented by @p email with the given @p params for the user encoded in @p url. + */ + SetDelegateJob* setDelegate( TDEIO::Slave* slave, const KURL& url, const TQString& email, int params ); + + /** + * Deletes the delegate represented by @p email for the user encoded in @p url. + */ + DeleteDelegateJob* deleteDelegate( TDEIO::Slave* slave, const KURL& url, const TQString& email ); + + /** + * Retrieves the delegates for the user encoded in @p url. + */ + GetDelegatesJob* getDelegates( TDEIO::Slave* slave, const KURL& url ); + + /** + * Adds the mailbox of another user represented by @p email to the users 'Other Users' namespace. + */ + AddOtherUserJob* addOtherUser( TDEIO::Slave* slave, const KURL& url, const TQString& email ); + + /** + * Deletes the mailbox of another user represented by @p email from the users 'Other Users' namespace. + */ + DeleteOtherUserJob* deleteOtherUser( TDEIO::Slave* slave, const KURL& url, const TQString& email ); + + /** + * Retrieves the list of all other users. + */ + GetOtherUsersJob* getOtherUsers( TDEIO::Slave* slave, const KURL& url ); + + /** + * Sets the out-of-office data. + * + * @param enabled Whether the out-of-office functionality is enabled. + * @param msg The out-of-office message. + */ + SetOutOfOfficeJob* setOutOfOffice( TDEIO::Slave* slave, const KURL& url, bool enabled, const TQString& msg ); + + /** + * Retrieves the out-of-office data. + */ + GetOutOfOfficeJob* getOutOfOffice( TDEIO::Slave* slave, const KURL& url ); + + + class SetPasswordJob : public TDEIO::SimpleJob + { + public: + SetPasswordJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + }; + + class SetDelegateJob : public TDEIO::SimpleJob + { + public: + SetDelegateJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + }; + + class DeleteDelegateJob : public TDEIO::SimpleJob + { + public: + DeleteDelegateJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + }; + + class GetDelegatesJob : public TDEIO::SimpleJob + { + Q_OBJECT + + + public: + GetDelegatesJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + + Delegate::List delegates() const; + + private slots: + void slotInfoMessage( TDEIO::Job*, const TQString& ); + + private: + Delegate::List mDelegates; + }; + + class AddOtherUserJob : public TDEIO::SimpleJob + { + public: + AddOtherUserJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + }; + + class DeleteOtherUserJob : public TDEIO::SimpleJob + { + public: + DeleteOtherUserJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + }; + + class GetOtherUsersJob : public TDEIO::SimpleJob + { + Q_OBJECT + + + public: + GetOtherUsersJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + + TQStringList otherUsers() const; + + private slots: + void slotInfoMessage( TDEIO::Job*, const TQString& ); + + private: + TQStringList mOtherUsers; + }; + + class SetOutOfOfficeJob : public TDEIO::SimpleJob + { + public: + SetOutOfOfficeJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + }; + + class GetOutOfOfficeJob : public TDEIO::SimpleJob + { + Q_OBJECT + + + public: + GetOutOfOfficeJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo ); + + bool enabled() const; + TQString message() const; + + private slots: + void slotInfoMessage( TDEIO::Job*, const TQString& ); + + private: + bool mEnabled; + TQString mMessage; + }; +} + +#endif diff --git a/tderesources/scalix/scalixadmin/ldapdialog.cpp b/tderesources/scalix/scalixadmin/ldapdialog.cpp new file mode 100644 index 000000000..6af08c4d7 --- /dev/null +++ b/tderesources/scalix/scalixadmin/ldapdialog.cpp @@ -0,0 +1,43 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <klocale.h> + +#include "ldapview.h" + +#include "ldapdialog.h" + +LdapDialog::LdapDialog( TQWidget *parent ) + : KDialogBase( parent, "", true, "", Ok | Cancel, Ok, true ) +{ + setCaption( i18n( "User Account Selection" ) ); + + mView = new LdapView( this ); + setMainWidget( mView ); + + mView->setQuery( "cn=*" ); + + resize( 400, 250 ); +} + +TQString LdapDialog::selectedUser() const +{ + return mView->selectedUser(); +} diff --git a/tderesources/scalix/scalixadmin/ldapdialog.h b/tderesources/scalix/scalixadmin/ldapdialog.h new file mode 100644 index 000000000..9d822af19 --- /dev/null +++ b/tderesources/scalix/scalixadmin/ldapdialog.h @@ -0,0 +1,39 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef LDAPDIALOG_H +#define LDAPDIALOG_H + +#include <kdialogbase.h> + +class LdapView; + +class LdapDialog : public KDialogBase +{ + public: + LdapDialog( TQWidget *parent = 0 ); + + TQString selectedUser() const; + + + private: + LdapView *mView; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/ldapview.cpp b/tderesources/scalix/scalixadmin/ldapview.cpp new file mode 100644 index 000000000..adf2fe3fa --- /dev/null +++ b/tderesources/scalix/scalixadmin/ldapview.cpp @@ -0,0 +1,99 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kabc/ldapclient.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include "settings.h" + +#include "ldapview.h" + +class LdapItem : public TQListViewItem +{ + public: + LdapItem( TQListView *parent, const TQString &text, const TQString &email ) + : TQListViewItem( parent ) + { + setText( 0, text ); + setText( 1, email ); + } +}; + + +LdapView::LdapView( TQWidget *parent ) + : KListView( parent ) +{ + addColumn( i18n( "User" ) ); + setFullWidth( true ); + + mClient = new KABC::LdapClient; + + mClient->setHost( Settings::self()->ldapHost() ); + mClient->setPort( Settings::self()->ldapPort() ); + mClient->setBase( Settings::self()->ldapBase() ); + mClient->setBindDN( Settings::self()->ldapBindDn() ); + mClient->setPwdBindDN( Settings::self()->ldapPassword() ); + + TQStringList attrs; + attrs << "surname" << "mail"; + mClient->setAttrs( attrs ); + + connect( mClient, TQT_SIGNAL( result( const KABC::LdapObject& ) ), + this, TQT_SLOT( entryAdded( const KABC::LdapObject& ) ) ); + connect( mClient, TQT_SIGNAL( error( const TQString& ) ), + this, TQT_SLOT( error( const TQString& ) ) ); +} + +LdapView::~LdapView() +{ + mClient->cancelQuery(); + delete mClient; +} + +TQString LdapView::selectedUser() const +{ + TQListViewItem *item = selectedItem(); + if ( !item ) + return TQString(); + else + return item->text( 1 ); +} + +void LdapView::setQuery( const TQString &query ) +{ + clear(); + mClient->startQuery( query ); +} + +void LdapView::entryAdded( const KABC::LdapObject &obj ) +{ + const TQString text = TQString( "%1 (%2)" ).arg( TQString(obj.attrs[ "surname" ].first()) ) + .arg( TQString(obj.attrs[ "mail" ].first()) ); + + new LdapItem( this, text, obj.attrs[ "mail" ].first() ); +} + +void LdapView::error( const TQString &msg ) +{ + KMessageBox::error( this, msg ); +} + +#include "ldapview.moc" diff --git a/tderesources/scalix/scalixadmin/ldapview.h b/tderesources/scalix/scalixadmin/ldapview.h new file mode 100644 index 000000000..6af41aa75 --- /dev/null +++ b/tderesources/scalix/scalixadmin/ldapview.h @@ -0,0 +1,52 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#ifndef LDAPVIEW_H +#define LDAPVIEW_H + +#include <klistview.h> + +namespace KABC { +class LdapClient; +class LdapObject; +} + +class LdapView : public KListView +{ + Q_OBJECT + + + public: + LdapView( TQWidget *parent = 0 ); + ~LdapView(); + + TQString selectedUser() const; + + public slots: + void setQuery( const TQString &query ); + + private slots: + void entryAdded( const KABC::LdapObject& ); + void error( const TQString& ); + + private: + KABC::LdapClient *mClient; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/main.cpp b/tderesources/scalix/scalixadmin/main.cpp new file mode 100644 index 000000000..6b9192a33 --- /dev/null +++ b/tderesources/scalix/scalixadmin/main.cpp @@ -0,0 +1,53 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +#include "mainwindow.h" + +static const char description[] = I18N_NOOP("Configuration Tool for Scalix Groupware Konnector"); + +static KCmdLineOptions options[] = +{ + KCmdLineLastOption +}; + +int main( int argc, char **argv ) +{ + TDEAboutData aboutData( "scalixadmin", I18N_NOOP("ScalixAdmin"), "1.0", description, + TDEAboutData::License_GPL, "(c) 2007, Tobias Koenig" ); + aboutData.addAuthor( "Tobias Koenig",0, "tokoe@kde.org" ); + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app; + + TDEGlobal::locale()->insertCatalogue( "scalixadmin" ); + + MainWindow *window = new MainWindow; + window->show(); + + app.setMainWidget( window ); + + return app.exec(); +} diff --git a/tderesources/scalix/scalixadmin/mainwindow.cpp b/tderesources/scalix/scalixadmin/mainwindow.cpp new file mode 100644 index 000000000..04e396d78 --- /dev/null +++ b/tderesources/scalix/scalixadmin/mainwindow.cpp @@ -0,0 +1,59 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqvbox.h> + +#include <kglobal.h> +#include <kiconloader.h> +#include <kjanuswidget.h> +#include <klocale.h> + +#include "delegatepage.h" +#include "otheruserpage.h" +#include "outofofficepage.h" +#include "passwordpage.h" + +#include "mainwindow.h" + +MainWindow::MainWindow() + : KMainWindow( 0 ) +{ + KJanusWidget *wdg = new KJanusWidget( this, "", KJanusWidget::IconList ); + + TQPixmap icon = TDEGlobal::iconLoader()->loadIcon( "folder_yellow", KIcon::Desktop ); + TQVBox *page = wdg->addVBoxPage( i18n( "Other Accounts" ), i18n( "Register other accounts" ), icon ); + new OtherUserPage( page ); + + icon = TDEGlobal::iconLoader()->loadIcon( "edu_languages", KIcon::Desktop ); + page = wdg->addVBoxPage( i18n( "Delegates" ), i18n( "Setup delegates for my account" ), icon ); + new DelegatePage( page ); + + icon = TDEGlobal::iconLoader()->loadIcon( "kontact_summary_green", KIcon::Desktop ); + page = wdg->addVBoxPage( i18n( "Out of Office..." ), i18n( "Setup Out of Office Message" ), icon ); + new OutOfOfficePage( page ); + + icon = TDEGlobal::iconLoader()->loadIcon( "password", KIcon::Desktop ); + page = wdg->addVBoxPage( i18n( "Password" ), i18n( "Change the password" ), icon ); + new PasswordPage( page ); + + setCentralWidget( wdg ); + + resize( 540, 450 ); +} diff --git a/tderesources/scalix/scalixadmin/mainwindow.h b/tderesources/scalix/scalixadmin/mainwindow.h new file mode 100644 index 000000000..38c955980 --- /dev/null +++ b/tderesources/scalix/scalixadmin/mainwindow.h @@ -0,0 +1,32 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <kmainwindow.h> + +class MainWindow : public KMainWindow +{ + public: + MainWindow(); +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/otherusermanager.cpp b/tderesources/scalix/scalixadmin/otherusermanager.cpp new file mode 100644 index 000000000..a3c19de12 --- /dev/null +++ b/tderesources/scalix/scalixadmin/otherusermanager.cpp @@ -0,0 +1,51 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "otherusermanager.h" + +OtherUserManager::OtherUserManager() +{ +} + +OtherUserManager::~OtherUserManager() +{ +} + +void OtherUserManager::addOtherUser( const TQString &email ) +{ + if ( !mOtherUsers.contains( email ) ) { + mOtherUsers.append( email ); + emit changed(); + } +} + +void OtherUserManager::clear() +{ + mOtherUsers.clear(); + + emit changed(); +} + +TQStringList OtherUserManager::otherUsers() const +{ + return mOtherUsers; +} + +#include "otherusermanager.moc" diff --git a/tderesources/scalix/scalixadmin/otherusermanager.h b/tderesources/scalix/scalixadmin/otherusermanager.h new file mode 100644 index 000000000..26f33ee4e --- /dev/null +++ b/tderesources/scalix/scalixadmin/otherusermanager.h @@ -0,0 +1,48 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef OTHERUSERMANAGER_H +#define OTHERUSERMANAGER_H + +#include <tqobject.h> +#include <tqstringlist.h> + +class OtherUserManager : public TQObject +{ + Q_OBJECT + + + public: + OtherUserManager(); + ~OtherUserManager(); + + void addOtherUser( const TQString &email ); + void clear(); + + TQStringList otherUsers() const; + + signals: + void changed(); + + private: + TQStringList mOtherUsers; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/otheruserpage.cpp b/tderesources/scalix/scalixadmin/otheruserpage.cpp new file mode 100644 index 000000000..3aac47c9e --- /dev/null +++ b/tderesources/scalix/scalixadmin/otheruserpage.cpp @@ -0,0 +1,173 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqapplication.h> +#include <tqlayout.h> +#include <tqpushbutton.h> + +#include <dcopref.h> +#include <kdcopservicestarter.h> +#include <kinputdialog.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include <unistd.h> + +#include "jobs.h" +#include "ldapdialog.h" +#include "otheruserview.h" +#include "settings.h" + +#include "otheruserpage.h" + +OtherUserPage::OtherUserPage( TQWidget *parent ) + : TQWidget( parent ) +{ + TQGridLayout *layout = new TQGridLayout( this, 2, 2, 11, 6 ); + + mView = new OtherUserView( &mManager, this ); + layout->addMultiCellWidget( mView, 0, 0, 0, 1 ); + + mAddButton = new TQPushButton( i18n( "Add Account..." ), this ); + layout->addWidget( mAddButton, 1, 0 ); + + mDeleteButton = new TQPushButton( i18n( "Remove Account" ), this ); + mDeleteButton->setEnabled( false ); + layout->addWidget( mDeleteButton, 1, 1 ); + + connect( mView, TQT_SIGNAL( selectionChanged() ), TQT_SLOT( selectionChanged() ) ); + connect( mAddButton, TQT_SIGNAL( clicked() ), TQT_SLOT( addUser() ) ); + connect( mDeleteButton, TQT_SIGNAL( clicked() ), TQT_SLOT( removeUser() ) ); + + loadAllUsers(); +} + +OtherUserPage::~OtherUserPage() +{ +} + +void OtherUserPage::loadAllUsers() +{ + Scalix::GetOtherUsersJob *job = Scalix::getOtherUsers( Settings::self()->globalSlave(), + Settings::self()->accountUrl() ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( allUsers( TDEIO::Job* ) ) ); +} + +void OtherUserPage::addUser() +{ + LdapDialog dlg( this ); + if ( !dlg.exec() ) + return; + + const TQString email = dlg.selectedUser(); + if ( email.isEmpty() ) + return; + + Scalix::AddOtherUserJob *job = Scalix::addOtherUser( Settings::self()->globalSlave(), + Settings::self()->accountUrl(), email ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( userAdded( TDEIO::Job* ) ) ); +} + +void OtherUserPage::removeUser() +{ + const TQString email = mView->selectedUser(); + if ( email.isEmpty() ) + return; + + Scalix::DeleteOtherUserJob *job = Scalix::deleteOtherUser( Settings::self()->globalSlave(), + Settings::self()->accountUrl(), email ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( userRemoved( TDEIO::Job* ) ) ); +} + +void OtherUserPage::allUsers( TDEIO::Job *job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); + + Scalix::GetOtherUsersJob *userJob = static_cast<Scalix::GetOtherUsersJob*>( job ); + + mManager.clear(); + + const TQStringList users = userJob->otherUsers(); + for ( uint i = 0; i < users.count(); ++i ) + mManager.addOtherUser( users[ i ] ); + + selectionChanged(); +} + +void OtherUserPage::userAdded( TDEIO::Job *job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); + else + loadAllUsers(); // update the GUI + + updateKmail(); +} + +void OtherUserPage::userRemoved( TDEIO::Job *job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); + else + loadAllUsers(); // update the GUI + + updateKmail(); +} + +void OtherUserPage::selectionChanged() +{ + mDeleteButton->setEnabled( mView->selectedItem() != 0 ); +} + +void OtherUserPage::updateKmail() +{ + TQMessageBox *msg = new TQMessageBox( tqApp->mainWidget() ); + msg->setText( i18n( "Updating account..." ) ); + msg->show(); + tqApp->processEvents(); + sleep( 1 ); + tqApp->processEvents(); + + TQString error; + TQCString dcopService; + int result = KDCOPServiceStarter::self()-> + findServiceFor( "DCOP/ResourceBackend/IMAP", TQString(), + TQString(), &error, &dcopService ); + if ( result != 0 ) { + KMessageBox::error( 0, i18n( "Unable to start KMail to trigger account update with Scalix server" ) ); + delete msg; + return; + } + + DCOPRef ref( dcopService, "KMailIface" ); + + // loop until dcop iface is set up correctly + TQStringList list; + while ( list.isEmpty() ) { + ref.call( "accounts()" ).get( list ); + } + + ref.call( "checkAccount(TQString)", i18n( "Scalix Server" ) ); + + delete msg; +} + +#include "otheruserpage.moc" diff --git a/tderesources/scalix/scalixadmin/otheruserpage.h b/tderesources/scalix/scalixadmin/otheruserpage.h new file mode 100644 index 000000000..e8c5e269d --- /dev/null +++ b/tderesources/scalix/scalixadmin/otheruserpage.h @@ -0,0 +1,61 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef OTHERUSERPAGE_H +#define OTHERUSERPAGE_H + +#include <tqwidget.h> + +#include "otherusermanager.h" + +class TQPushButton; +class OtherUserView; + +class OtherUserPage : public TQWidget +{ + Q_OBJECT + + + public: + OtherUserPage( TQWidget *parent = 0 ); + ~OtherUserPage(); + + private slots: + void loadAllUsers(); + void addUser(); + void removeUser(); + + void userAdded( TDEIO::Job* ); + void userRemoved( TDEIO::Job* ); + void allUsers( TDEIO::Job* ); + + void selectionChanged(); + + private: + void updateKmail(); + + TQPushButton *mAddButton; + TQPushButton *mDeleteButton; + + OtherUserManager mManager; + OtherUserView *mView; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/otheruserview.cpp b/tderesources/scalix/scalixadmin/otheruserview.cpp new file mode 100644 index 000000000..25a694287 --- /dev/null +++ b/tderesources/scalix/scalixadmin/otheruserview.cpp @@ -0,0 +1,71 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <klocale.h> + +#include "otherusermanager.h" + +#include "otheruserview.h" + +class OtherUserItem : public TQListViewItem +{ + public: + OtherUserItem( TQListView *parent, const TQString &user ) + : TQListViewItem( parent ), mUser( user ) + { + setText( 0, mUser ); + } + + TQString user() const { return mUser; } + + private: + TQString mUser; +}; + +OtherUserView::OtherUserView( OtherUserManager *manager, TQWidget *parent ) + : KListView( parent ), mManager( manager ) +{ + addColumn( i18n( "Registered Accounts" ) ); + setFullWidth( true ); + + connect( mManager, TQT_SIGNAL( changed() ), TQT_SLOT( userChanged() ) ); + + userChanged(); +} + +TQString OtherUserView::selectedUser() const +{ + OtherUserItem *item = dynamic_cast<OtherUserItem*>( selectedItem() ); + if ( item ) + return item->user(); + + return TQString(); +} + +void OtherUserView::userChanged() +{ + clear(); + + TQStringList users = mManager->otherUsers(); + for ( uint i = 0; i < users.count(); ++i ) + new OtherUserItem( this, users[ i ] ); +} + +#include "otheruserview.moc" diff --git a/tderesources/scalix/scalixadmin/otheruserview.h b/tderesources/scalix/scalixadmin/otheruserview.h new file mode 100644 index 000000000..b5d3ff00e --- /dev/null +++ b/tderesources/scalix/scalixadmin/otheruserview.h @@ -0,0 +1,45 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef OTHERUSERVIEW_H +#define OTHERUSERVIEW_H + +#include <klistview.h> + +class OtherUserManager; + +class OtherUserView : public KListView +{ + Q_OBJECT + + + public: + OtherUserView( OtherUserManager *manager, TQWidget *parent = 0 ); + + TQString selectedUser() const; + + private slots: + void userChanged(); + + private: + OtherUserManager *mManager; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/outofofficepage.cpp b/tderesources/scalix/scalixadmin/outofofficepage.cpp new file mode 100644 index 000000000..4e34a9144 --- /dev/null +++ b/tderesources/scalix/scalixadmin/outofofficepage.cpp @@ -0,0 +1,125 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqbuttongroup.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqpushbutton.h> +#include <tqradiobutton.h> +#include <tqtextedit.h> + +#include <klocale.h> +#include <kmessagebox.h> + +#include "jobs.h" +#include "settings.h" + +#include "outofofficepage.h" + +OutOfOfficePage::OutOfOfficePage( TQWidget *parent ) + : TQWidget( parent ) +{ + TQGridLayout *layout = new TQGridLayout( this, 4, 2, 11, 6 ); + + TQButtonGroup *group = new TQButtonGroup( 1, Qt::Vertical, this ); + + mDisabled = new TQRadioButton( i18n( "I am in the office" ), group ); + mDisabled->setChecked( true ); + mEnabled = new TQRadioButton( i18n( "I am out of the office" ), group ); + + mLabel = new TQLabel( i18n( "Auto-reply once to each sender with the following text:" ), this ); + mMessage = new TQTextEdit( this ); + mSaveButton = new TQPushButton( i18n( "Save" ), this ); + + layout->addMultiCellWidget( group, 0, 0, 0, 1 ); + layout->addMultiCellWidget( mLabel, 1, 1, 0, 1 ); + layout->addMultiCellWidget( mMessage, 2, 2, 0, 1 ); + layout->addWidget( mSaveButton, 3, 1 ); + + statusChanged(); + + connect( mEnabled, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( statusChanged() ) ); + connect( mEnabled, TQT_SIGNAL( toggled( bool ) ), this, TQT_SLOT( changed() ) ); + connect( mSaveButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( store() ) ); + connect( mMessage, TQT_SIGNAL( textChanged() ), this, TQT_SLOT( changed() ) ); + + load(); +} + +OutOfOfficePage::~OutOfOfficePage() +{ +} + +void OutOfOfficePage::load() +{ + Scalix::GetOutOfOfficeJob *job = Scalix::getOutOfOffice( Settings::self()->globalSlave(), + Settings::self()->accountUrl() ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( loaded( TDEIO::Job* ) ) ); +} + +void OutOfOfficePage::loaded( TDEIO::Job* job ) +{ + if ( job->error() ) { + KMessageBox::error( this, job->errorString() ); + return; + } + + Scalix::GetOutOfOfficeJob *outOfOfficeJob = static_cast<Scalix::GetOutOfOfficeJob*>( job ); + + mEnabled->setChecked( outOfOfficeJob->enabled() ); + mMessage->setText( outOfOfficeJob->message() ); + + statusChanged(); + + mSaveButton->setEnabled( false ); +} + +void OutOfOfficePage::store() +{ + Scalix::SetOutOfOfficeJob *job = Scalix::setOutOfOffice( Settings::self()->globalSlave(), + Settings::self()->accountUrl(), + mEnabled->isChecked(), + mMessage->text() ); + + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), TQT_SLOT( stored( TDEIO::Job* ) ) ); + + mSaveButton->setEnabled( false ); +} + +void OutOfOfficePage::stored( TDEIO::Job* job ) +{ + if ( job->error() ) + KMessageBox::error( this, job->errorString() ); +} + +void OutOfOfficePage::statusChanged() +{ + bool state = mEnabled->isChecked(); + + mLabel->setEnabled( state ); + mMessage->setEnabled( state ); +} + +void OutOfOfficePage::changed() +{ + mSaveButton->setEnabled( true ); +} + +#include "outofofficepage.moc" diff --git a/tderesources/scalix/scalixadmin/outofofficepage.h b/tderesources/scalix/scalixadmin/outofofficepage.h new file mode 100644 index 000000000..f9863fa18 --- /dev/null +++ b/tderesources/scalix/scalixadmin/outofofficepage.h @@ -0,0 +1,58 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef OUTOFOFFICEPAGE_H +#define OUTOFOFFICEPAGE_H + +#include <tqwidget.h> + +class TQLabel; +class TQPushButton; +class TQRadioButton; +class TQTextEdit; + +class OutOfOfficePage : public TQWidget +{ + Q_OBJECT + + + public: + OutOfOfficePage( TQWidget *parent = 0 ); + ~OutOfOfficePage(); + + private slots: + void load(); + void loaded( TDEIO::Job* ); + void store(); + void stored( TDEIO::Job* ); + void statusChanged(); + void changed(); + + private: + TQRadioButton *mEnabled; + TQRadioButton *mDisabled; + TQLabel *mLabel; + TQTextEdit *mMessage; + TQPushButton *mSaveButton; + + bool mChanged; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/passwordpage.cpp b/tderesources/scalix/scalixadmin/passwordpage.cpp new file mode 100644 index 000000000..6dd8ab10e --- /dev/null +++ b/tderesources/scalix/scalixadmin/passwordpage.cpp @@ -0,0 +1,190 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <tqapplication.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlineedit.h> +#include <tqpushbutton.h> + +#include <kconfig.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstringhandler.h> +#include <tdewallet.h> + +#include "jobs.h" +#include "settings.h" + +#include "passwordpage.h" + +PasswordPage::PasswordPage( TQWidget *parent ) + : TQWidget( parent ), mJob( 0 ) +{ + TQGridLayout *layout = new TQGridLayout( this, 2, 3, 11, 6 ); + + TQLabel *label = new TQLabel( i18n( "New password:" ), this ); + layout->addWidget( label, 0, 0 ); + + mPassword = new TQLineEdit( this ); + mPassword->setEchoMode( TQLineEdit::Password ); + label->setBuddy( mPassword ); + layout->addWidget( mPassword, 0, 1 ); + + label = new TQLabel( i18n( "Retype new password:" ), this ); + layout->addWidget( label, 1, 0 ); + + mPasswordRetype = new TQLineEdit( this ); + mPasswordRetype->setEchoMode( TQLineEdit::Password ); + label->setBuddy( mPasswordRetype ); + layout->addWidget( mPasswordRetype, 1, 1 ); + + mButton = new TQPushButton( i18n( "Change" ), this ); + mButton->setEnabled( false ); + layout->addWidget( mButton, 2, 1 ); + + layout->setRowSpacing( 3, 1 ); + + connect( mPassword, TQT_SIGNAL( textChanged( const TQString& ) ), this, TQT_SLOT( textChanged() ) ); + connect( mPasswordRetype, TQT_SIGNAL( textChanged( const TQString& ) ), this, TQT_SLOT( textChanged() ) ); + connect( mButton, TQT_SIGNAL( clicked() ), this, TQT_SLOT( buttonClicked() ) ); +} + +void PasswordPage::buttonClicked() +{ + if ( !mJob ) { + if ( mPassword->text() != mPasswordRetype->text() ) { + KMessageBox::error( this, i18n( "The two passwords differ!" ) ); + return; + } + + mJob = Scalix::setPassword( Settings::self()->globalSlave(), Settings::self()->accountUrl(), + Settings::self()->accountPassword(), mPassword->text() ); + connect( mJob, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( finished( TDEIO::Job* ) ) ); + + updateState( true ); + } else { + mJob->kill(); + mJob = 0; + + updateState( false ); + } +} + +void PasswordPage::updateState( bool isWorking ) +{ + if ( isWorking ) { + mPassword->setEnabled( false ); + mPasswordRetype->setEnabled( false ); + mButton->setText( i18n( "Stop" ) ); + } else { + mPassword->setEnabled( true ); + mPasswordRetype->setEnabled( true ); + mButton->setText( i18n( "Change" ) ); + } +} + +void PasswordPage::textChanged() +{ + mButton->setEnabled( !mPassword->text().isEmpty() && + !mPasswordRetype->text().isEmpty() ); +} + +void PasswordPage::finished( TDEIO::Job* job ) +{ + mJob = 0; + + updateState( false ); + + if ( job->error() ) { + KMessageBox::error( this, i18n( "Unable to change the password" ) + "\n" + job->errorString() ); + return; + } + + // Update configuration files to the new password as well + + const TQString newPassword = mPassword->text(); + + { // ScalixAdmin config + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "Account" ); + group.writeEntry( "pass", KStringHandler::obscure( newPassword ) ); + } + + { // ScalixWizard config + TDEConfig config( "scalixrc" ); + TDEConfigGroup group( &config, "General" ); + group.writeEntry( "Password", KStringHandler::obscure( newPassword ) ); + } + + { // KMail config + TDEConfig config( "kmailrc" ); + + // Try to find account group for Scalix + TQString scalixAccount; + const TQStringList groupList = config.groupList(); + for ( uint i = 0; i < groupList.count(); ++i ) { + if ( groupList[ i ].startsWith( "Account " ) ) { + TDEConfigGroup group( &config, groupList[ i ] ); + if ( group.hasKey( "groupwareType" ) && group.readNumEntry( "groupwareType" ) == 2 ) { + scalixAccount = groupList[ i ]; + break; + } + } + } + + if ( scalixAccount.isEmpty() ) { + tqWarning( "No Scalix Groupware Account found in kmailrc!" ); + return; + } + + const int accountId = scalixAccount.mid( 8 ).toInt(); + + TDEConfigGroup group( &config, scalixAccount ); + + // Save only if the user choose it before + bool storePassword = group.readBoolEntry( "store-passwd", false ); + if ( storePassword ) { + // First try to store in KWallet + if ( KWallet::Wallet::isEnabled() ) { + WId window = 0; + if ( tqApp->activeWindow() ) + window = tqApp->activeWindow()->winId(); + + KWallet::Wallet *wallet = KWallet::Wallet::openWallet( KWallet::Wallet::NetworkWallet(), window ); + if ( wallet ) { + if ( !wallet->hasFolder( "kmail" ) ) + wallet->createFolder( "kmail" ); + wallet->setFolder( "kmail" ); + wallet->writePassword( "account-" + TQString::number( accountId ), newPassword ); + } + } else { + group.writeEntry( "pass", KStringHandler::obscure( newPassword ) ); + } + + TDEConfigGroup fileGroup( &config, TQString( "Folder-%1" ).arg( group.readNumEntry( "Folder" ) ) ); + fileGroup.writeEntry( "pass", KStringHandler::obscure( newPassword ) ); + } + } + + KMessageBox::information( this, i18n( "Password was changed successfully" ) ); +} + +#include "passwordpage.moc" diff --git a/tderesources/scalix/scalixadmin/passwordpage.h b/tderesources/scalix/scalixadmin/passwordpage.h new file mode 100644 index 000000000..5255193e8 --- /dev/null +++ b/tderesources/scalix/scalixadmin/passwordpage.h @@ -0,0 +1,56 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef PASSWORDPAGE_H +#define PASSWORDPAGE_H + +#include <tqwidget.h> + +class TQLineEdit; +class TQPushButton; + +namespace TDEIO { +class Job; +} + +class PasswordPage : public TQWidget +{ + Q_OBJECT + + + public: + PasswordPage( TQWidget *parent = 0 ); + + private slots: + void buttonClicked(); + void finished( TDEIO::Job* ); + void textChanged(); + + private: + void updateState( bool ); + + TQLineEdit *mPassword; + TQLineEdit *mPasswordRetype; + TQPushButton *mButton; + + TDEIO::Job *mJob; +}; + +#endif diff --git a/tderesources/scalix/scalixadmin/settings.cpp b/tderesources/scalix/scalixadmin/settings.cpp new file mode 100644 index 000000000..279491c5f --- /dev/null +++ b/tderesources/scalix/scalixadmin/settings.cpp @@ -0,0 +1,136 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include <kconfig.h> +#include <kio/scheduler.h> +#include <kstringhandler.h> + +#include "settings.h" + +Settings* Settings::mSelf = 0; + +Settings::Settings() +{ + mSlave = TDEIO::Scheduler::getConnectedSlave( accountUrl(), + accountData() ); +} + +Settings::~Settings() +{ +} + +Settings* Settings::self() +{ + if ( !mSelf ) + mSelf = new Settings; + + return mSelf; +} + +TDEIO::MetaData Settings::accountData() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "Account" ); + + TDEIO::MetaData data; + data.insert( "auth", group.readEntry( "auth" ) ); + data.insert( "tls", group.readBoolEntry( "use-tls" ) ? "on" : "off" ); + + return data; +} + +KURL Settings::accountUrl() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "Account" ); + + KURL url; + url.setProtocol( group.readBoolEntry( "use-ssl" ) ? "imaps" : "imap" ); + url.setUser( group.readEntry( "user" ) ); + url.setPass( KStringHandler::obscure( group.readEntry( "pass" ) ) ); + url.setHost( group.readEntry( "host" ) ); + url.setPort( group.readNumEntry( "port" ) ); + + return url; +} + +TQString Settings::accountPassword() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "Account" ); + + return KStringHandler::obscure( group.readEntry( "pass" ) ); +} + +TDEIO::Slave* Settings::globalSlave() const +{ + return mSlave; +} + +TQString Settings::rulesWizardUrl() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "Misc" ); + + TQString url = group.readEntry( "rulesWizardUrl" ); + if ( url.isEmpty() ) { + TDEConfigGroup group( &config, "Account" ); + url = TQString( "http://%1/Scalix/rw/?username=%2" ).arg( group.readEntry( "host" ) ) + .arg( group.readEntry( "user" ) ); + } + + return url; +} + +TQString Settings::ldapHost() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "LDAP" ); + return group.readEntry( "host" ); +} + +TQString Settings::ldapPort() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "LDAP" ); + return group.readEntry( "port" ); +} + +TQString Settings::ldapBase() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "LDAP" ); + return group.readEntry( "base" ); +} + +TQString Settings::ldapBindDn() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "LDAP" ); + return group.readEntry( "bindDn" ); +} + +TQString Settings::ldapPassword() const +{ + TDEConfig config( "scalixadminrc" ); + TDEConfigGroup group( &config, "LDAP" ); + return group.readEntry( "password" ); +} + diff --git a/tderesources/scalix/scalixadmin/settings.h b/tderesources/scalix/scalixadmin/settings.h new file mode 100644 index 000000000..29028f3b8 --- /dev/null +++ b/tderesources/scalix/scalixadmin/settings.h @@ -0,0 +1,56 @@ +/* + * This file is part of ScalixAdmin. + * + * Copyright (C) 2007 Trolltech ASA. All rights reserved. + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include <kurl.h> +#include <kio/global.h> +#include <kio/slave.h> + +class Settings +{ + public: + ~Settings(); + + static Settings* self(); + + TDEIO::MetaData accountData() const; + KURL accountUrl() const; + TQString accountPassword() const; + + TDEIO::Slave *globalSlave() const; + + TQString rulesWizardUrl() const; + + TQString ldapHost() const; + TQString ldapPort() const; + TQString ldapBase() const; + TQString ldapBindDn() const; + TQString ldapPassword() const; + + private: + Settings(); + TDEIO::Slave *mSlave; + + static Settings* mSelf; +}; + +#endif |