libkcal
calhelper.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00032 #include "calhelper.h"
00033 #include "calendarresources.h"
00034
00035 using namespace KCal;
00036
00037 bool CalHelper::isMyKolabIncidence( Calendar *calendar, Incidence *incidence )
00038 {
00039 CalendarResources *cal = dynamic_cast<CalendarResources*>( calendar );
00040 if ( !cal || !incidence ) {
00041 return true;
00042 }
00043
00044 CalendarResourceManager *manager = cal->resourceManager();
00045 CalendarResourceManager::Iterator it;
00046 for ( it = manager->begin(); it != manager->end(); ++it ) {
00047 QString subRes = (*it)->subresourceIdentifier( incidence );
00048 if ( !subRes.isEmpty() && !subRes.contains( "/.INBOX.directory/" ) ) {
00049 return false;
00050 }
00051 }
00052 return true;
00053 }
00054
00055 bool CalHelper::isMyCalendarIncidence( Calendar *calendar, Incidence *incidence )
00056 {
00057 return isMyKolabIncidence( calendar, incidence );
00058 }
00059
00060 Incidence *CalHelper::findMyCalendarIncidenceByUid( Calendar *calendar, const QString &uid )
00061 {
00062
00063 Incidence *existingIncidence = 0;
00064 if ( calendar ) {
00065 existingIncidence = calendar->incidence( uid );
00066 if ( !isMyCalendarIncidence( calendar, existingIncidence ) ) {
00067 existingIncidence = 0;
00068 }
00069 if ( !existingIncidence ) {
00070 const Incidence::List list = calendar->incidences();
00071 for ( Incidence::List::ConstIterator it = list.begin(), end = list.end(); it != end; ++it ) {
00072 if ( (*it)->schedulingID() == uid && isMyCalendarIncidence( calendar, *it ) ) {
00073 existingIncidence = *it;
00074 break;
00075 }
00076 }
00077 }
00078 }
00079 return existingIncidence;
00080 }
00081
00082 bool CalHelper::usingGroupware( Calendar *calendar )
00083 {
00084 CalendarResources *cal = dynamic_cast<CalendarResources*>( calendar );
00085 if ( !cal ) {
00086 return true;
00087 }
00088
00089 CalendarResourceManager *manager = cal->resourceManager();
00090 CalendarResourceManager::Iterator it;
00091 for ( it = manager->begin(); it != manager->end(); ++it ) {
00092 QString res = (*it)->type();
00093 if ( res == "imap" ) {
00094 return true;
00095 }
00096 }
00097 return false;
00098 }
00099
00100 bool CalHelper::hasMyWritableEventsFolders( Calendar *calendar )
00101 {
00102 CalendarResources *cal = dynamic_cast<CalendarResources*>( calendar );
00103 if ( !cal ) {
00104 return true;
00105 }
00106
00107 CalendarResourceManager *manager = cal->resourceManager();
00108
00109 CalendarResourceManager::ActiveIterator it;
00110 for ( it=manager->activeBegin(); it != manager->activeEnd(); ++it ) {
00111 if ( (*it)->readOnly() ) {
00112 continue;
00113 }
00114
00115 const QStringList subResources = (*it)->subresources();
00116 if ( subResources.isEmpty() ) {
00117 return true;
00118 }
00119
00120 QStringList::ConstIterator subIt;
00121 for ( subIt=subResources.begin(); subIt != subResources.end(); ++subIt ) {
00122 if ( !(*it)->subresourceActive( (*subIt) ) ) {
00123 continue;
00124 }
00125 if ( (*it)->type() == "imap" || (*it)->type() == "kolab" ) {
00126 if ( (*it)->subresourceType( ( *subIt ) ) == "todo" ||
00127 (*it)->subresourceType( ( *subIt ) ) == "journal" ||
00128 !(*subIt).contains( "/.INBOX.directory/" ) ) {
00129 continue;
00130 }
00131 }
00132 return true;
00133 }
00134 }
00135 return false;
00136 }
|