diff options
Diffstat (limited to 'kopete/protocols/groupwise/libgroupwise/tasks/needfoldertask.cpp')
-rw-r--r-- | kopete/protocols/groupwise/libgroupwise/tasks/needfoldertask.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/kopete/protocols/groupwise/libgroupwise/tasks/needfoldertask.cpp b/kopete/protocols/groupwise/libgroupwise/tasks/needfoldertask.cpp new file mode 100644 index 00000000..810326ee --- /dev/null +++ b/kopete/protocols/groupwise/libgroupwise/tasks/needfoldertask.cpp @@ -0,0 +1,58 @@ +// +// C++ Implementation: %{MODULE} +// +// Description: +// +// +// Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR} +// +// Copyright: See COPYING file that comes with this distribution +// +// +#include "client.h" +#include "tasks/createcontactinstancetask.h" +#include "tasks/createfoldertask.h" + +#include "needfoldertask.h" + +NeedFolderTask::NeedFolderTask(Task* parent): ModifyContactListTask(parent) +{ +} + +NeedFolderTask::~NeedFolderTask() +{ +} + +void NeedFolderTask::createFolder() +{ + CreateFolderTask * cct = new CreateFolderTask( client()->rootTask() ); + cct->folder( 0, m_folderSequence, m_folderDisplayName ); + connect( cct, SIGNAL( gotFolderAdded( const FolderItem & ) ), client(), SIGNAL( folderReceived( const FolderItem & ) ) ); + connect( cct, SIGNAL( gotFolderAdded( const FolderItem & ) ), SLOT( slotFolderAdded( const FolderItem & ) ) ); + connect( cct, SIGNAL( finished() ), SLOT( slotFolderTaskFinished() ) ); + cct->go( true ); +} + +void NeedFolderTask::slotFolderAdded( const FolderItem & addedFolder ) +{ + // if this is the folder we were trying to create + if ( m_folderDisplayName == addedFolder.name ) + { + client()->debug( QString( "NeedFolderTask::slotFolderAdded() - Folder %1 was created on the server, now has objectId %2" ).arg( addedFolder.name ).arg( addedFolder.id ) ); + m_folderId = addedFolder.id; + } +} + +void NeedFolderTask::slotFolderTaskFinished() +{ + CreateFolderTask *cct = ( CreateFolderTask* )sender(); + if ( cct->success() ) + { + // call our child class's action to be performed + onFolderCreated(); + } + else + setError( 1, "Folder creation failed" ); +} + +#include "needfoldertask.moc" |