You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
307 lines
9.7 KiB
307 lines
9.7 KiB
15 years ago
|
/*
|
||
|
* 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 )
|
||
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
Delegate::Delegate( const TQString &email, int rights )
|
||
15 years ago
|
: mEmail( email ), mRights( rights )
|
||
|
{
|
||
|
}
|
||
|
|
||
|
bool Delegate::isValid() const
|
||
|
{
|
||
|
return ( !mEmail.isEmpty() && mRights != -1 );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString Delegate::email() const
|
||
15 years ago
|
{
|
||
|
return mEmail;
|
||
|
}
|
||
|
|
||
|
int Delegate::rights() const
|
||
|
{
|
||
|
return mRights;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString Delegate::rightsAsString( int rights )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQStringList rightNames;
|
||
15 years ago
|
|
||
|
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( ", " );
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
SetPasswordJob* Scalix::setPassword( TDEIO::Slave* slave, const KURL& url,
|
||
14 years ago
|
const TQString &oldPassword, const TQString& newPassword )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
13 years ago
|
<< TQString( "X-SCALIX-PASSWORD" ) << TQString( "%1 %2" ).arg( oldPassword ).arg( newPassword );
|
||
15 years ago
|
|
||
|
SetPasswordJob* job = new SetPasswordJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
SetDelegateJob* Scalix::setDelegate( TDEIO::Slave* slave, const KURL& url, const TQString& email, int params )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQStringList types;
|
||
15 years ago
|
if ( params & SendOnBehalfOf )
|
||
|
types.append( "SOBO" );
|
||
|
if ( params & SeePrivate )
|
||
|
types.append( "SEEPRIVATE" );
|
||
|
if ( params & GetMeetings )
|
||
|
types.append( "GETMEETINGS" );
|
||
|
if ( params & InsteadOfMe )
|
||
|
types.append( "INSTEADOFME" );
|
||
|
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
13 years ago
|
<< TQString( "X-SET-DELEGATE" ) << TQString( "%1 %2" ).arg( email ).arg( types.join( " " ) );
|
||
15 years ago
|
|
||
|
SetDelegateJob* job = new SetDelegateJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
DeleteDelegateJob* Scalix::deleteDelegate( TDEIO::Slave* slave, const KURL& url, const TQString& email )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
14 years ago
|
<< TQString( "X-DELETE-DELEGATE" ) << email;
|
||
15 years ago
|
|
||
|
DeleteDelegateJob* job = new DeleteDelegateJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
GetDelegatesJob* Scalix::getDelegates( TDEIO::Slave* slave, const KURL& url )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
|
stream << (int)'X' << (int)'N' << TQString( "X-GET-DELEGATES" ) << TQString();
|
||
15 years ago
|
|
||
|
GetDelegatesJob* job = new GetDelegatesJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
AddOtherUserJob* Scalix::addOtherUser( TDEIO::Slave* slave, const KURL& url, const TQString& email )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
14 years ago
|
<< TQString( "X-ADD-OTHER-USER" ) << email;
|
||
15 years ago
|
|
||
|
AddOtherUserJob* job = new AddOtherUserJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
DeleteOtherUserJob* Scalix::deleteOtherUser( TDEIO::Slave* slave, const KURL& url, const TQString& email )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
14 years ago
|
<< TQString( "X-DELETE-OTHER-USER" ) << email;
|
||
15 years ago
|
|
||
|
DeleteOtherUserJob* job = new DeleteOtherUserJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
GetOtherUsersJob* Scalix::getOtherUsers( TDEIO::Slave* slave, const KURL& url )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
14 years ago
|
<< TQString( "X-GET-OTHER-USERS" ) << TQString();
|
||
15 years ago
|
|
||
|
GetOtherUsersJob* job = new GetOtherUsersJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
SetOutOfOfficeJob* Scalix::setOutOfOffice( TDEIO::Slave* slave, const KURL& url, bool enabled, const TQString& msg )
|
||
15 years ago
|
{
|
||
14 years ago
|
const TQString argument = msg;
|
||
13 years ago
|
const TQString command = TQString( "X-SET-OUT-OF-OFFICE %1 %2 {%3}" ).arg( enabled ? "ENABLED" : "DISABLED" )
|
||
|
.arg( "UTF-8" )
|
||
|
.arg( msg.utf8().length() );
|
||
15 years ago
|
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int) 'X' << (int)'E' << command << argument;
|
||
|
|
||
|
SetOutOfOfficeJob* job = new SetOutOfOfficeJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
12 years ago
|
GetOutOfOfficeJob* Scalix::getOutOfOffice( TDEIO::Slave* slave, const KURL& url )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQByteArray packedArgs;
|
||
|
TQDataStream stream( packedArgs, IO_WriteOnly );
|
||
15 years ago
|
stream << (int)'X' << (int)'N'
|
||
14 years ago
|
<< TQString( "X-GET-OUT-OF-OFFICE" ) << TQString();
|
||
15 years ago
|
|
||
|
GetOutOfOfficeJob* job = new GetOutOfOfficeJob( url, packedArgs, false );
|
||
12 years ago
|
TDEIO::Scheduler::assignJobToSlave( slave, job );
|
||
15 years ago
|
return job;
|
||
|
}
|
||
|
|
||
14 years ago
|
SetPasswordJob::SetPasswordJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
SetDelegateJob::SetDelegateJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
DeleteDelegateJob::DeleteDelegateJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
GetDelegatesJob::GetDelegatesJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
12 years ago
|
connect( this, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ),
|
||
|
this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
Delegate::List GetDelegatesJob::delegates() const
|
||
|
{
|
||
|
return mDelegates;
|
||
|
}
|
||
|
|
||
12 years ago
|
void GetDelegatesJob::slotInfoMessage( TDEIO::Job*, const TQString &data )
|
||
15 years ago
|
{
|
||
|
/**
|
||
|
* The passed data have the following form:
|
||
|
*
|
||
|
* "user1@host.com:right1,right2,right4 user2@host.com:right3,right5"
|
||
|
*/
|
||
14 years ago
|
TQStringList delegates = TQStringList::split( ' ', data );
|
||
15 years ago
|
for ( uint i = 0; i < delegates.count(); ++i ) {
|
||
14 years ago
|
TQStringList delegate = TQStringList::split( ':', delegates[ i ] );
|
||
15 years ago
|
|
||
14 years ago
|
const TQString email = delegate[ 0 ];
|
||
15 years ago
|
int rights = 0;
|
||
|
|
||
14 years ago
|
TQStringList rightsList = TQStringList::split( ',', delegate[ 1 ] );
|
||
15 years ago
|
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 ) );
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
AddOtherUserJob::AddOtherUserJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
DeleteOtherUserJob::DeleteOtherUserJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
GetOtherUsersJob::GetOtherUsersJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
12 years ago
|
connect( this, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ),
|
||
|
this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
TQStringList GetOtherUsersJob::otherUsers() const
|
||
15 years ago
|
{
|
||
|
return mOtherUsers;
|
||
|
}
|
||
|
|
||
12 years ago
|
void GetOtherUsersJob::slotInfoMessage( TDEIO::Job*, const TQString &data )
|
||
15 years ago
|
{
|
||
14 years ago
|
mOtherUsers = TQStringList::split( ' ', data );
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
SetOutOfOfficeJob::SetOutOfOfficeJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
GetOutOfOfficeJob::GetOutOfOfficeJob( const KURL& url, const TQByteArray &packedArgs, bool showProgressInfo )
|
||
12 years ago
|
: TDEIO::SimpleJob( url, TDEIO::CMD_SPECIAL, packedArgs, showProgressInfo )
|
||
15 years ago
|
{
|
||
12 years ago
|
connect( this, TQT_SIGNAL( infoMessage( TDEIO::Job*, const TQString& ) ),
|
||
|
this, TQT_SLOT( slotInfoMessage( TDEIO::Job*, const TQString& ) ) );
|
||
15 years ago
|
}
|
||
|
|
||
|
bool GetOutOfOfficeJob::enabled() const
|
||
|
{
|
||
|
return mEnabled;
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString GetOutOfOfficeJob::message() const
|
||
15 years ago
|
{
|
||
|
return mMessage;
|
||
|
}
|
||
|
|
||
12 years ago
|
void GetOutOfOfficeJob::slotInfoMessage( TDEIO::Job*, const TQString &data )
|
||
15 years ago
|
{
|
||
14 years ago
|
const TQStringList fields = TQStringList::split( '^', data );
|
||
15 years ago
|
|
||
|
mEnabled = ( fields[ 0 ] == "ENABLED" );
|
||
|
mMessage = fields[ 1 ];
|
||
|
}
|
||
|
|
||
|
#include "jobs.moc"
|