konsolekalendarvariables.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <klocale.h>
00020 #include <kdebug.h>
00021 #include <kglobal.h>
00022 #include <kconfig.h>
00023 #include <kstandarddirs.h>
00024 #include <kglobalsettings.h>
00025
00026
00027 #include <qdatetime.h>
00028 #include <qstring.h>
00029 #include <qstringlist.h>
00030
00031 #include <stdlib.h>
00032 #include <iostream>
00033 #include <stdio.h>
00034 #include <unistd.h>
00035 #include <time.h>
00036
00037
00038
00039 #include "konsolekalendarvariables.h"
00040
00041 using namespace KCal;
00042 using namespace std;
00043
00044 KonsoleKalendarVariables::KonsoleKalendarVariables()
00045 {
00046 m_TimeZoneId = "";
00047 m_bIsTimeZoneId = false;
00048 m_bIsUID = false;
00049 m_bIsStartDateTime = false;
00050 m_bIsEndDateTime = false;
00051 m_bNext = false;
00052 m_bVerbose = false;
00053 m_bDryRun = false;
00054 m_bDescription = false;
00055 m_description = "Default description";
00056 m_bSummary = false;
00057 m_summary = "Default summary";
00058 m_bFloating = true;
00059 m_export_type = TEXT_KONSOLEKALENDAR;
00060 m_bIsExportFile = false;
00061 m_bIsDefault = false;
00062 m_bIsCalendarResources = false;
00063 }
00064
00065
00066
00067 void KonsoleKalendarVariables::setTimeZoneId()
00068 {
00069
00070
00071
00072 QString zone;
00073
00074
00075 char zonefilebuf[100];
00076 int len = readlink("/etc/localtime",zonefilebuf,100);
00077 if (len > 0 && len < 100) {
00078 zonefilebuf[len] = '\0';
00079 zone = zonefilebuf;
00080 zone = zone.mid(zone.find("zoneinfo/") + 9);
00081 kdDebug() << "konsolekalendarvariables.cpp::setTimeZoneId() | system timezone from /etc/localtime is " << zone << endl;
00082 } else {
00083 tzset();
00084 zone = tzname[0];
00085 kdDebug() << "konsolekalendarvariables.cpp::setTimeZoneId() | system timezone from tzset() is " << zone << endl;
00086 }
00087
00088
00089 KConfig korgcfg( locate( "config", QString::fromLatin1("korganizerrc") ) );
00090 korgcfg.setGroup( "Time & Date" );
00091 QString tz(korgcfg.readEntry( "TimeZoneId" ) );
00092 if ( ! tz.isEmpty() ) {
00093 zone = tz;
00094 kdDebug() << "konsolekalendarvariables.cpp::setTimeZoneId() | timezone from korganizerrc is " << zone << endl;
00095 }
00096
00097 m_bIsTimeZoneId = true;
00098 m_TimeZoneId = zone;
00099 }
00100
00101 QString KonsoleKalendarVariables::getTimeZoneId()
00102 {
00103 return m_TimeZoneId;
00104 }
00105
00106 bool KonsoleKalendarVariables::isTimeZoneId()
00107 {
00108 return m_bIsTimeZoneId;
00109 }
00110
00111 KonsoleKalendarVariables::~KonsoleKalendarVariables()
00112 {
00113
00114 }
00115
00116 void KonsoleKalendarVariables::setUID(QString uid)
00117 {
00118 m_bIsUID = true;
00119 m_UID = uid;
00120 }
00121
00122 QString KonsoleKalendarVariables::getUID()
00123 {
00124 return m_UID;
00125 }
00126
00127 bool KonsoleKalendarVariables::isUID()
00128 {
00129 return m_bIsUID;
00130 }
00131
00132 void KonsoleKalendarVariables::setStartDateTime(QDateTime start)
00133 {
00134 m_bIsStartDateTime = true;
00135 m_startDateTime = start;
00136 }
00137
00138 QDateTime KonsoleKalendarVariables::getStartDateTime()
00139 {
00140 return m_startDateTime;
00141 }
00142
00143 bool KonsoleKalendarVariables::isStartDateTime()
00144 {
00145 return m_bIsStartDateTime;
00146 }
00147
00148 void KonsoleKalendarVariables::setEndDateTime(QDateTime end)
00149 {
00150 m_bIsEndDateTime = true;
00151 m_endDateTime = end;
00152 }
00153
00154 QDateTime KonsoleKalendarVariables::getEndDateTime()
00155 {
00156 return m_endDateTime;
00157 }
00158
00159 bool KonsoleKalendarVariables::isEndDateTime()
00160 {
00161 return m_bIsEndDateTime;
00162 }
00163
00164 void KonsoleKalendarVariables::setNext(bool next)
00165 {
00166 m_bNext = next;
00167 }
00168
00169 bool KonsoleKalendarVariables::isNext()
00170 {
00171 return m_bNext;
00172 }
00173
00174 void KonsoleKalendarVariables::setVerbose(bool verbose)
00175 {
00176 m_bVerbose = verbose;
00177 }
00178
00179 bool KonsoleKalendarVariables::isVerbose()
00180 {
00181 return m_bVerbose;
00182 }
00183
00184 void KonsoleKalendarVariables::setDryRun(bool dryrun)
00185 {
00186 m_bDryRun = dryrun;
00187 }
00188
00189 bool KonsoleKalendarVariables::isDryRun()
00190 {
00191 return m_bDryRun;
00192 }
00193
00194 void KonsoleKalendarVariables::setCalendarFile(QString calendar)
00195 {
00196 m_calendar = calendar;
00197 }
00198
00199 QString KonsoleKalendarVariables::getCalendarFile()
00200 {
00201 return m_calendar;
00202 }
00203
00204 void KonsoleKalendarVariables::setImportFile(QString calendar)
00205 {
00206 m_import = calendar;
00207 }
00208
00209 QString KonsoleKalendarVariables::getImportFile()
00210 {
00211 return m_import;
00212 }
00213
00214
00215 void KonsoleKalendarVariables::setCalendar( CalendarLocal *calendar )
00216 {
00217 m_calendarLocal = calendar;
00218 }
00219
00220 CalendarLocal *KonsoleKalendarVariables::getCalendar()
00221 {
00222 return m_calendarLocal;
00223 }
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 void KonsoleKalendarVariables::setExportType( int export_type )
00238 {
00239 m_export_type = export_type;
00240 }
00241
00242 int KonsoleKalendarVariables::getExportType()
00243 {
00244 return m_export_type;
00245 }
00246
00247 void KonsoleKalendarVariables::setExportFile( QString export_file )
00248 {
00249 m_exportFile = export_file;
00250 m_bIsExportFile = true;
00251 }
00252
00253 bool KonsoleKalendarVariables::isExportFile()
00254 {
00255 return m_bIsExportFile;
00256 }
00257
00258 QString KonsoleKalendarVariables::getExportFile()
00259 {
00260 return m_exportFile;
00261 }
00262
00263 bool KonsoleKalendarVariables::isAll()
00264 {
00265 return m_bAll;
00266 }
00267
00268 void KonsoleKalendarVariables::setAll( bool all)
00269 {
00270 m_bAll = all;
00271 }
00272
00273 bool KonsoleKalendarVariables::getAll()
00274 {
00275 return m_bAll;
00276 }
00277
00278 void KonsoleKalendarVariables::setDefault( bool def )
00279 {
00280 m_bIsDefault = def;
00281 }
00282
00283
00284 bool KonsoleKalendarVariables::isDefault()
00285 {
00286 return m_bIsDefault;
00287 }
00288
00289 void KonsoleKalendarVariables::setDescription(QString description)
00290 {
00291 m_bDescription = true;
00292 m_description = description;
00293 }
00294
00295 QString KonsoleKalendarVariables::getDescription()
00296 {
00297 return m_description;
00298 }
00299
00300 bool KonsoleKalendarVariables::isDescription()
00301 {
00302 return m_bDescription;
00303 }
00304
00305 void KonsoleKalendarVariables::setSummary(QString summary)
00306 {
00307 m_bSummary = true;
00308 m_summary = summary;
00309 }
00310
00311 QString KonsoleKalendarVariables::getSummary()
00312 {
00313 return m_summary;
00314 }
00315
00316 bool KonsoleKalendarVariables::isSummary()
00317 {
00318 return m_bSummary;
00319 }
00320
00321 void KonsoleKalendarVariables::setFloating(bool floating)
00322 {
00323 m_bFloating = floating;
00324 }
00325
00326 bool KonsoleKalendarVariables::getFloating()
00327 {
00328 return m_bFloating;
00329 }
00330
00331 void KonsoleKalendarVariables::setDaysCount( int count ){
00332 m_daysCount = count;
00333 m_bDaysCount = true;
00334 }
00335
00336 int KonsoleKalendarVariables::getDaysCount(){
00337 return m_daysCount;
00338 }
00339
00340 bool KonsoleKalendarVariables::isDaysCount(){
00341 return m_bDaysCount;
00342 }
00343
00344
00345
00346 bool KonsoleKalendarVariables::addCalendarResources( ResourceCalendar *resource )
00347 {
00348 if ( m_resource ) {
00349
00350
00351 kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | Add to calendar resource!" << endl;
00352
00353 CalendarResourceManager::ActiveIterator it;
00354 CalendarResourceManager *manager = getCalendarResourceManager();
00355 QString fileName = NULL;
00356
00357 for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
00358 kdDebug() << "Resource name: " + (*it)->resourceName() << endl;
00359
00360 if( !strcmp( (*it)->resourceName().local8Bit(), getCalendarFile().local8Bit() ) ){
00361 kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | We allready have this resource" << endl;
00362 return true;
00363 }
00364
00365 }
00366
00367 manager->add( resource );
00368
00369 if( isDefault() ) {
00370 kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | Make it default" << endl;
00371 manager->setStandardResource( resource );
00372 }
00373
00374 } else {
00375 kdDebug() << "konsoleKalendarvariables.cpp::addCalendarResources() | Cannot add to calendar resources (Not created!)" << endl;
00376 return false;
00377 }
00378
00379 return true;
00380 }
00381
00382 bool KonsoleKalendarVariables::isCalendarResources()
00383 {
00384 return m_bIsCalendarResources;
00385 }
00386
00387 void KonsoleKalendarVariables::setCalendarResources( CalendarResources *resource )
00388 {
00389 m_resource = resource;
00390 setCalendar( ((CalendarLocal *)m_resource) );
00391 m_bIsCalendarResources = true;
00392 }
00393
00394 CalendarResources *KonsoleKalendarVariables::getCalendarResources()
00395 {
00396 return m_resource;
00397 }
00398
00399
00400 CalendarResourceManager *KonsoleKalendarVariables::getCalendarResourceManager( )
00401 {
00402 return m_resource->resourceManager();
00403 }
00404
00405 bool KonsoleKalendarVariables::loadCalendarResources( KConfig *config )
00406 {
00407
00408 if ( m_resource ) {
00409
00410 kdDebug() << "konsoleKalendarvariables.cpp::loadCalendarResources() | loading resources" << endl;
00411
00412 CalendarResourceManager *manager = m_resource->resourceManager();
00413
00414 if ( manager->isEmpty() == true ) {
00415
00416 config->setGroup("General");
00417 QString fileName = config->readPathEntry( "Active Calendar" );
00418
00419 QString resourceName;
00420 if ( fileName.isEmpty() ) {
00421 fileName = locateLocal( "appdata", "std.ics" );
00422 resourceName = i18n("Default KOrganizer resource");
00423 } else {
00424 resourceName = i18n("Active Calendar");
00425 }
00426
00427 kdDebug() << "konsoleKalendarvariables.cpp::loadCalendarResources() | Using as default resource: '" << fileName << "'" << endl;
00428
00429 ResourceCalendar *defaultResource = new ResourceLocal( fileName );
00430
00431 defaultResource->setResourceName( resourceName );
00432
00433 manager->add( defaultResource );
00434 manager->setStandardResource( defaultResource );
00435 }
00436 }
00437
00438 return true;
00439 }
This file is part of the documentation for konsolekalendar Library Version 3.2.2.