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 TQString 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 TQString &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 TQString res = (*it)->type();
00093 if ( res == "imap" ) {
00094 return true;
00095 }
00096 }
00097 return false;
00098 }
00099
00100 bool CalHelper::hasMyWritableEventsFolders( const TQString &family )
00101 {
00102 TQString myfamily = family;
00103 if ( family.isEmpty() ) {
00104 myfamily = "calendar";
00105 }
00106
00107 CalendarResourceManager manager( myfamily );
00108 manager.readConfig();
00109
00110 CalendarResourceManager::ActiveIterator it;
00111 for ( it=manager.activeBegin(); it != manager.activeEnd(); ++it ) {
00112 if ( (*it)->readOnly() ) {
00113 continue;
00114 }
00115
00116 const TQStringList subResources = (*it)->subresources();
00117 if ( subResources.isEmpty() ) {
00118 return true;
00119 }
00120
00121 TQStringList::ConstIterator subIt;
00122 for ( subIt=subResources.begin(); subIt != subResources.end(); ++subIt ) {
00123 if ( !(*it)->subresourceActive( (*subIt) ) ) {
00124 continue;
00125 }
00126 if ( (*it)->type() == "imap" || (*it)->type() == "kolab" ) {
00127 if ( (*it)->subresourceType( ( *subIt ) ) == "todo" ||
00128 (*it)->subresourceType( ( *subIt ) ) == "journal" ||
00129 !(*subIt).contains( "/.INBOX.directory/" ) ) {
00130 continue;
00131 }
00132 }
00133 return true;
00134 }
00135 }
00136 return false;
00137 }
00138
00139 ResourceCalendar *CalHelper::incResourceCalendar( Calendar *calendar, Incidence *incidence )
00140 {
00141 CalendarResources *cal = dynamic_cast<CalendarResources*>( calendar );
00142 if ( !cal || !incidence ) {
00143 return 0;
00144 }
00145
00146 return cal->resource( incidence );
00147 }
00148
00149 TQPair<ResourceCalendar *, TQString> CalHelper::incSubResourceCalendar( Calendar *calendar,
00150 Incidence *incidence )
00151 {
00152 TQPair<ResourceCalendar *, TQString> p( 0, TQString() );
00153
00154 CalendarResources *cal = dynamic_cast<CalendarResources*>( calendar );
00155 if ( !cal || !incidence ) {
00156 return p;
00157 }
00158
00159 ResourceCalendar *res = cal->resource( incidence );
00160
00161 TQString subRes;
00162 if ( res && res->canHaveSubresources() ) {
00163 subRes = res->subresourceIdentifier( incidence );
00164 }
00165 p = tqMakePair( res, subRes );
00166 return p;
00167 }
|