Be able to mark folders as having groupware contents. And check in the icalIface stuff to match up the imap resource again

svn path=/trunk/kdepim/; revision=310641
wilder-work
Bo Thorsen 22 years ago
parent 669fabaca8
commit ddaeabecb5
  1. 3
      kmailicalIface.h
  2. 93
      kmailicalifaceimpl.cpp
  3. 15
      kmailicalifaceimpl.h
  4. 17
      kmfolder.cpp
  5. 7
      kmfolder.h
  6. 30
      kmfolderdia.cpp
  7. 1
      kmfolderdia.h

@ -60,6 +60,9 @@ k_dcop_signals:
const QString& entry );
void incidenceDeleted( const QString& type, const QString& folder,
const QString& uid );
void signalRefresh( const QString& type, const QString& folder );
void subresourceAdded( const QString& type, const QString& resource );
void subresourceDeleted( const QString& type, const QString& resource );
};
#endif

@ -59,6 +59,36 @@
static void vPartMicroParser( const QString& str, QString& s );
static void reloadFolderTree();
// Local helper class
class KMailICalIfaceImpl::ExtraFolder {
public:
ExtraFolder( KMFolder* f, int t ) : folder( f ), type( t ) {}
KMFolder* folder;
int type;
};
static QString folderContentsType( int type )
{
switch( type ) {
case 1: return "Calendar";
case 2: return "Contact";
case 3: return "Note";
case 4: return "Task";
case 5: return "Journal";
default: return "Mail";
}
}
static int folderContentsType( const QString& type )
{
if ( type == "Calendar" ) return 1;
if ( type == "Contact" ) return 2;
if ( type == "Note" ) return 3;
if ( type == "Task" ) return 4;
if ( type == "Journal" ) return 5;
return 0;
}
/*
This interface have three parts to it - libkcal interface;
kmail interface; and helper functions.
@ -77,6 +107,8 @@ KMailICalIfaceImpl::KMailICalIfaceImpl()
{
// Listen to config changes
connect( kmkernel, SIGNAL( configChanged() ), this, SLOT( readConfig() ) );
mExtraFolders.setAutoDelete( true );
}
// Receive an iCal or vCard from the resource
@ -480,6 +512,43 @@ void KMailICalIfaceImpl::deleteMsg( KMMessage *msg )
( new KMDeleteMsgCommand( msg->parent(), msg ) )->start();
}
void KMailICalIfaceImpl::folderContentsTypeChanged( KMFolder* folder,
int contentsType )
{
kdDebug(5006) << "folderContentsTypeChanged( " << folder->name()
<< ", " << contentsType << ")\n";
// Find previous type of this folder
ExtraFolder* ef = mExtraFolders.find( folder->location() );
if ( ( ef && ef->type == contentsType ) || ( !ef && contentsType == 0 ) )
// Nothing to tell!
return;
if ( ef ) {
// Notify that the old folder resource is no longer available
dcopEmit( "subresourceDeleted(QString,QString)",
folderContentsType( ef->type ), folder->location() );
if ( contentsType == 0 ) {
// Delete the old entry and stop here
mExtraFolders.remove( folder->location() );
return;
}
// So the type changed to another groupware type.
// Set the entry to the new type
ef->type = contentsType;
} else {
// Make a new entry for the list
ef = new ExtraFolder( folder, contentsType );
mExtraFolders.insert( folder->location(), ef );
}
// Tell about the new resource
dcopEmit( "subresourceAdded(QString,QString)",
folderContentsType( contentsType ), folder->location() );
}
/****************************
* The config stuff
*/
@ -714,6 +783,30 @@ QPixmap* KMailICalIfaceImpl::pixCalendar;
QPixmap* KMailICalIfaceImpl::pixNotes;
QPixmap* KMailICalIfaceImpl::pixTasks;
void KMailICalIfaceImpl::dcopEmit( const QCString& signal, const QString& arg0,
const QString& arg1, const QString& arg2 )
{
QByteArray data;
QDataStream arg( data, IO_WriteOnly );
arg << arg0;
QCString s = signal + "(QString";
if ( arg1 != QString::null ) {
arg << arg1;
s += ",QString";
}
if ( arg2 != QString::null ) {
arg << arg2;
s += ",QString";
}
s += ")";
kdDebug(5006) << "Emitting DCOP signal " << s << " with args ( " << arg0
<< ( arg1 == QString::null ? QString() : ", " + arg1 )
<< ( arg2 == QString::null ? QString() : ", " + arg2 )
<< " )" << endl;
emitDCOPSignal( s, data );
}
static void reloadFolderTree()
{
// Make the folder tree show the icons or not

@ -35,10 +35,11 @@
#define KMAILICALIFACEIMPL_H
#include "kmailicalIface.h"
#include "kmfoldertype.h"
#include <kfoldertree.h>
#include "kmfoldertype.h"
#include <qdict.h>
class KMFolder;
class KMMessage;
@ -117,6 +118,9 @@ public:
bool isEnabled() const { return mUseResourceIMAP; }
/** Called when a folders contents have changed */
void folderContentsTypeChanged( KMFolder*, int );
public slots:
/* (Re-)Read configuration file */
void readConfig();
@ -136,6 +140,11 @@ private:
/** Helper function for initFolders. Initializes a single folder. */
KMFolder* initFolder( KFolderTreeItem::Type itemType, const char* typeString );
/** Emit a dcop signal */
void dcopEmit( const QCString& signal, const QString& arg0,
const QString& arg1 = QString::null,
const QString& arg2 = QString::null );
void loadPixmaps() const;
KMFolder* mContacts;
@ -144,6 +153,10 @@ private:
KMFolder* mTasks;
KMFolder* mJournals;
// The extra IMAP resource folders
class ExtraFolder;
QDict<ExtraFolder> mExtraFolders;
unsigned int mFolderLanguage;
KMFolderDir* mFolderParent;

@ -14,6 +14,7 @@
#include "kmfoldermgr.h"
#include "identitymanager.h"
#include "kmidentity.h"
#include "kmailicalifaceimpl.h"
#include "expirejob.h"
#include <errno.h>
@ -32,7 +33,7 @@ KMFolder::KMFolder( KMFolderDir* aParent, const QString& aFolderName,
mExpireMessages( false ), mUnreadExpireAge( 28 ),
mReadExpireAge( 14 ), mUnreadExpireUnits( expireNever ),
mReadExpireUnits( expireNever ),
mUseCustomIcons( false ), mMailingListEnabled( false )
mUseCustomIcons( false ), mMailingListEnabled( false ), mContentsType( 0 )
{
if( aFolderType == KMFolderTypeCachedImap )
mStorage = new KMFolderCachedImap( this, aFolderName.latin1() );
@ -115,6 +116,8 @@ void KMFolder::readConfig( KConfig* config )
mId = config->readUnsignedNumEntry("Id", 0);
mPutRepliesInSameFolder = config->readBoolEntry( "PutRepliesInSameFolder", false );
setContentsType( config->readNumEntry( "ContentsType", 0 ) );
if ( mUseCustomIcons )
emit iconsChanged();
}
@ -140,6 +143,8 @@ void KMFolder::writeConfig( KConfig* config ) const
config->writeEntry("WhoField", mUserWhoField);
config->writeEntry("Id", mId);
config->writeEntry( "PutRepliesInSameFolder", mPutRepliesInSameFolder );
config->writeEntry( "ContentsType", mContentsType );
}
KMFolderType KMFolder::folderType() const
@ -686,6 +691,16 @@ KMFolder* KMFolder::trashFolder() const
return mStorage ? mStorage->trashFolder() : 0;
}
void KMFolder::setContentsType( int type )
{
// Damage control. Shouldn't happen to be used, but resort to mail anyway
if ( type < 0 || type > 5 ) type = 0;
if ( type != mContentsType ) {
mContentsType = type;
kmkernel->iCalIface().folderContentsTypeChanged( this, type );
}
}
int KMFolder::writeIndex( bool createEmptyIndex )
{
return mStorage->writeIndex( createEmptyIndex );

@ -473,6 +473,9 @@ public:
bool putRepliesInSameFolder() const { return mPutRepliesInSameFolder; }
void setPutRepliesInSameFolder( bool b ) { mPutRepliesInSameFolder = b; }
void setContentsType( int type );
int contentsType() const { return mContentsType; }
signals:
/** Emitted when the status, name, or associated accounts of this
folder changed. */
@ -566,6 +569,10 @@ private:
/** Should replies to messages in this folder be put in here? */
bool mPutRepliesInSameFolder;
/** Type of contents in this folder. */
// TODO: Make this an enum
int mContentsType;
};
#endif /*kmfolder_h*/

@ -44,6 +44,7 @@
#include "mailinglist-magic.h"
#include "kmfoldertree.h"
#include "folderdiaacltab.h"
#include "kmailicalifaceimpl.h"
#include <keditlistbox.h>
#include <klineedit.h>
@ -459,6 +460,31 @@ KMail::FolderDiaGeneralTab::FolderDiaGeneralTab( KMFolderDialog* dlg,
sl->addWidget( mShowSenderReceiverComboBox );
sl->addStretch( 1 );
if ( kmkernel->iCalIface().isEnabled() &&
!kmkernel->iCalIface().isResourceImapFolder( mDlg->folder() ) ) {
// Only do make this settable, if the IMAP resource is enabled
// and it's not the personal folders (those must not be changed)
QGroupBox *typeGroup = new QGroupBox( i18n("Contents" ), this );
typeGroup->setColumnLayout( 0, Qt::Vertical );
QHBoxLayout *typeLayout = new QHBoxLayout( typeGroup->layout() );
typeLayout->setSpacing( 6 );
topLayout->addWidget( typeGroup );
label = new QLabel( i18n("&Folder contents:"), typeGroup );
typeLayout->addWidget( label );
mContentsComboBox = new QComboBox( typeGroup );
label->setBuddy( mContentsComboBox );
typeLayout->addWidget( mContentsComboBox, 3 );
mContentsComboBox->insertItem( i18n( "Mail" ) );
mContentsComboBox->insertItem( i18n( "Calendar" ) );
mContentsComboBox->insertItem( i18n( "Contacts" ) );
mContentsComboBox->insertItem( i18n( "Notes" ) );
mContentsComboBox->insertItem( i18n( "Tasks" ) );
mContentsComboBox->insertItem( i18n( "Journal" ) );
mContentsComboBox->setCurrentItem( mDlg->folder()->contentsType() );
} else
mContentsComboBox = 0;
// should this folder be included in new-mail-checks?
QGroupBox* newmailGroup = new QGroupBox( i18n("Check for New Mail"), this, "newmailGroup" );
newmailGroup->setColumnLayout( 0, Qt::Vertical );
@ -785,6 +811,10 @@ bool FolderDiaGeneralTab::save()
else
folder->setUserWhoField(QString::null);
// Set type field
if ( mContentsComboBox )
mDlg->folder()->setContentsType( mContentsComboBox->currentItem() );
if( mDlg->isNewFolder() )
folder->close();

@ -141,6 +141,7 @@ private:
QComboBox *mBelongsToComboBox;
QComboBox *mMailboxTypeComboBox;
QComboBox *mShowSenderReceiverComboBox;
QComboBox *mContentsComboBox;
QLineEdit *mNameEdit;
QLabel *mNormalIconLabel;
KIconButton *mNormalIconButton;

Loading…
Cancel
Save