konsolekalendar Library API Documentation

konsolekalendarvariables.cpp

00001 /*******************************************************************************
00002  * konsolekalendarvariables.cpp                                                *
00003  *                                                                             *
00004  * KonsoleKalendar is a command line interface to KDE calendars                *
00005  * Copyright (C) 2002-2004  Tuukka Pasanen <illuusio@mailcity.com>             *
00006  * Copyright (C) 2003-2004  Allen Winter <awinterz@users.sourceforge.net>      *
00007  *                                                                             *
00008  * This program is free software; you can redistribute it and/or modify        *
00009  * it under the terms of the GNU General Public License as published by        *
00010  * the Free Software Foundation; either version 2 of the License, or           *
00011  * (at your option) any later version.                                         *
00012  *                                                                             *
00013  * This program is distributed in the hope that it will be useful,             *
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                *
00016  * GNU General Public License for more details.                                *
00017  *                                                                             *
00018  * You should have received a copy of the GNU General Public License           *
00019  * along with this program; if not, write to the Free Software                 *
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. *
00021  *                                                                             *
00022  * As a special exception, permission is given to link this program            *
00023  * with any edition of Qt, and distribute the resulting executable,            *
00024  * without including the source code for Qt in the source distribution.        *
00025  *                                                                             *
00026  ******************************************************************************/
00027 
00028 #include <klocale.h>
00029 #include <kdebug.h>
00030 #include <kglobal.h>
00031 #include <kconfig.h>
00032 #include <kstandarddirs.h>
00033 #include <kglobalsettings.h>
00034 #include <kpimprefs.h>
00035 
00036 #include <qdatetime.h>
00037 #include <qstring.h>
00038 #include <qstringlist.h>
00039 
00040 #include <stdlib.h>
00041 #include <iostream>
00042 #include <stdio.h>
00043 #include <unistd.h>
00044 #include <time.h>
00045 
00046 #include "konsolekalendarvariables.h"
00047 
00048 using namespace KCal;
00049 using namespace std;
00050 
00051 KonsoleKalendarVariables::KonsoleKalendarVariables()
00052 {
00053   m_TimeZoneId = "";
00054   m_bIsTimeZoneId = false;
00055   m_bIsUID = false;
00056   m_bIsStartDateTime = false;
00057   m_bIsEndDateTime = false;
00058   m_bNext = false;
00059   m_bVerbose = false;
00060   m_bDryRun = false;
00061   m_bDescription = false;
00062   m_description = "";
00063   m_bSummary = false;
00064   m_summary = "Default summary";
00065   m_bFloating = true;
00066   m_export_type = TEXT_KONSOLEKALENDAR;
00067   m_bIsExportFile = false;
00068   m_bIsDefault = false;
00069   m_bIsCalendarResources = false;
00070 }
00071 
00072 void KonsoleKalendarVariables::setTimeZoneId()
00073 {
00074   m_bIsTimeZoneId = true;
00075   m_TimeZoneId = KPimPrefs::timezone();
00076 }
00077 
00078 QString KonsoleKalendarVariables::getTimeZoneId()
00079 {
00080   return m_TimeZoneId;
00081 }
00082 
00083 bool KonsoleKalendarVariables::isTimeZoneId()
00084 {
00085   return m_bIsTimeZoneId;
00086 }
00087 
00088 KonsoleKalendarVariables::~KonsoleKalendarVariables()
00089 {
00090   // delete m_resource;
00091 }
00092 
00093 void KonsoleKalendarVariables::setUID(QString uid)
00094 {
00095   m_bIsUID = true;
00096   m_UID = uid;
00097 }
00098 
00099 QString KonsoleKalendarVariables::getUID()
00100 {
00101   return m_UID;
00102 }
00103 
00104 bool KonsoleKalendarVariables::isUID()
00105 {
00106   return m_bIsUID;
00107 }
00108 
00109 void KonsoleKalendarVariables::setStartDateTime(QDateTime start)
00110 {
00111   m_bIsStartDateTime = true;
00112   m_startDateTime = start;
00113 }
00114 
00115 QDateTime KonsoleKalendarVariables::getStartDateTime()
00116 {
00117   return m_startDateTime;
00118 }
00119 
00120 bool KonsoleKalendarVariables::isStartDateTime()
00121 {
00122   return m_bIsStartDateTime;
00123 }
00124 
00125 void KonsoleKalendarVariables::setEndDateTime(QDateTime end)
00126 {
00127   m_bIsEndDateTime = true;
00128   m_endDateTime = end;
00129 }
00130 
00131 QDateTime KonsoleKalendarVariables::getEndDateTime()
00132 {
00133   return m_endDateTime;
00134 }
00135 
00136 bool KonsoleKalendarVariables::isEndDateTime()
00137 {
00138   return m_bIsEndDateTime;
00139 }
00140 
00141 void KonsoleKalendarVariables::setNext(bool next)
00142 {
00143   m_bNext = next;
00144 }
00145 
00146 bool KonsoleKalendarVariables::isNext()
00147 {
00148   return m_bNext;
00149 }
00150 
00151 void KonsoleKalendarVariables::setVerbose(bool verbose)
00152 {
00153   m_bVerbose = verbose;
00154 }
00155 
00156 bool KonsoleKalendarVariables::isVerbose()
00157 {
00158   return m_bVerbose;
00159 }
00160 
00161 void KonsoleKalendarVariables::setDryRun(bool dryrun)
00162 {
00163   m_bDryRun = dryrun;
00164 }
00165 
00166 bool KonsoleKalendarVariables::isDryRun()
00167 {
00168   return m_bDryRun;
00169 }
00170 
00171 void KonsoleKalendarVariables::setCalendarFile(QString calendar)
00172 {
00173   m_calendar = calendar;
00174 }
00175 
00176 QString KonsoleKalendarVariables::getCalendarFile()
00177 {
00178   return m_calendar;
00179 }
00180 
00181 void KonsoleKalendarVariables::setImportFile(QString calendar)
00182 {
00183   m_import = calendar;
00184 }
00185 
00186 QString KonsoleKalendarVariables::getImportFile()
00187 {
00188   return m_import;
00189 }
00190 
00191 void KonsoleKalendarVariables::setCalendar( CalendarLocal *calendar )
00192 {
00193   m_calendarLocal = calendar;
00194 }
00195 
00196 CalendarLocal *KonsoleKalendarVariables::getCalendar()
00197 {
00198   return m_calendarLocal;
00199 }
00200 
00201 void KonsoleKalendarVariables::setExportType( int export_type )
00202 {
00203   m_export_type = export_type;
00204 }
00205 
00206 int KonsoleKalendarVariables::getExportType()
00207 {
00208   return m_export_type;
00209 }
00210 
00211 void KonsoleKalendarVariables::setExportFile( QString export_file )
00212 {
00213   m_exportFile = export_file;
00214   m_bIsExportFile = true;
00215 }
00216 
00217 bool KonsoleKalendarVariables::isExportFile()
00218 {
00219   return m_bIsExportFile;
00220 }
00221 
00222 QString KonsoleKalendarVariables::getExportFile()
00223 {
00224   return m_exportFile;
00225 }
00226 
00227 bool KonsoleKalendarVariables::isAll()
00228 {
00229   return m_bAll;
00230 }
00231 
00232 void KonsoleKalendarVariables::setAll( bool all)
00233 {
00234   m_bAll = all;
00235 }
00236 
00237 bool KonsoleKalendarVariables::getAll()
00238 {
00239   return m_bAll;
00240 }
00241 
00242 void KonsoleKalendarVariables::setDefault( bool def )
00243 {
00244   m_bIsDefault = def;
00245 }
00246 
00247 bool KonsoleKalendarVariables::isDefault()
00248 {
00249   return m_bIsDefault;
00250 }
00251 
00252 void KonsoleKalendarVariables::setDescription(QString description)
00253 {
00254   m_bDescription = true;
00255   m_description = description;
00256 }
00257 
00258 QString KonsoleKalendarVariables::getDescription()
00259 {
00260   return m_description;
00261 }
00262 
00263 bool KonsoleKalendarVariables::isDescription()
00264 {
00265   return m_bDescription;
00266 }
00267 
00268 void KonsoleKalendarVariables::setLocation(QString location)
00269 {
00270   m_bLocation = true;
00271   m_location = location;
00272 }
00273 
00274 QString KonsoleKalendarVariables::getLocation()
00275 {
00276   return m_location;
00277 }
00278 
00279 bool KonsoleKalendarVariables::isLocation()
00280 {
00281   return m_bLocation;
00282 }
00283 
00284 void KonsoleKalendarVariables::setSummary(QString summary)
00285 {
00286   m_bSummary = true;
00287   m_summary = summary;
00288 }
00289 
00290 QString KonsoleKalendarVariables::getSummary()
00291 {
00292   return m_summary;
00293 }
00294 
00295 bool KonsoleKalendarVariables::isSummary()
00296 {
00297   return m_bSummary;
00298 }
00299 
00300 void KonsoleKalendarVariables::setFloating(bool floating)
00301 {
00302   m_bFloating = floating;
00303 }
00304 
00305 bool KonsoleKalendarVariables::getFloating()
00306 {
00307   return m_bFloating;
00308 }
00309 
00310 void KonsoleKalendarVariables::setDaysCount( int count ) {
00311   m_daysCount = count;
00312   m_bDaysCount = true;
00313 }
00314 
00315 int KonsoleKalendarVariables::getDaysCount() {
00316   return m_daysCount;
00317 }
00318 
00319 bool KonsoleKalendarVariables::isDaysCount() {
00320   return m_bDaysCount;
00321 }
00322 
00323 bool KonsoleKalendarVariables::addCalendarResources(ResourceCalendar *resource)
00324 {
00325   if ( m_resource ) {
00326     // In current state we support only one calendar
00327     // that's a fact and we have to live with that!
00328     kdDebug() << "konsolekalendarvariables.cpp::addCalendarResources() | "
00329               << "Add to calendar resource!"
00330               << endl;
00331 
00332     CalendarResourceManager::ActiveIterator it;
00333     CalendarResourceManager *manager = getCalendarResourceManager();
00334     QString fileName = NULL;
00335 
00336     for ( it = manager->activeBegin(); it != manager->activeEnd(); ++it ) {
00337       kdDebug() << "Resource name: " + (*it)->resourceName()
00338                 << endl;
00339 
00340       if ( !strcmp( (*it)->resourceName().local8Bit(),
00341                     getCalendarFile().local8Bit() ) ) {
00342     kdDebug() << "konsolekalendarvariables.cpp::addCalendarResources() | "
00343                   << "We allready have this resource"
00344                   << endl;
00345         return true;
00346       }
00347 
00348     }
00349 
00350     manager->add( resource );
00351 
00352     if ( isDefault() ) {
00353       kdDebug() << "konsolekalendarvariables.cpp::addCalendarResources() | "
00354                 << "Make it default"
00355                 << endl;
00356       manager->setStandardResource( resource );
00357     }
00358 
00359   } else {
00360     kdDebug() << "konsolekalendarvariables.cpp::addCalendarResources() | "
00361               << "Cannot add to calendar resources (Not created!)"
00362               << endl;
00363     return false;
00364   }
00365 
00366   return true;
00367 }
00368 
00369 bool KonsoleKalendarVariables::isCalendarResources()
00370 {
00371   return m_bIsCalendarResources;
00372 }
00373 
00374 void KonsoleKalendarVariables::setCalendarResources(CalendarResources *resource)
00375 {
00376   m_resource = resource;
00377   setCalendar( (CalendarLocal *) m_resource );
00378   m_bIsCalendarResources = true;
00379 }
00380 
00381 CalendarResources *KonsoleKalendarVariables::getCalendarResources()
00382 {
00383   return m_resource;
00384 }
00385 
00386 CalendarResourceManager *KonsoleKalendarVariables::getCalendarResourceManager( )
00387 {
00388   return m_resource->resourceManager();
00389 }
00390 
00391 bool KonsoleKalendarVariables::loadCalendarResources( KConfig *config )
00392 {
00393 
00394   if ( m_resource ) {
00395     kdDebug() << "konsolekalendarvariables.cpp::loadCalendarResources() | "
00396               << "loading resources"
00397               << endl;
00398 
00399     CalendarResourceManager *manager = m_resource->resourceManager();
00400 
00401     if ( manager->isEmpty() == true ) {
00402 
00403       config->setGroup("General");
00404       QString fileName = config->readPathEntry( "Active Calendar" );
00405 
00406       QString resourceName;
00407       if ( fileName.isEmpty() ) {
00408         fileName = locateLocal( "appdata", "std.ics" );
00409         resourceName = i18n("Default KOrganizer resource");
00410       } else {
00411         resourceName = i18n("Active Calendar");
00412       }
00413 
00414       kdDebug() << "konsolekalendarvariables.cpp::loadCalendarResources() | "
00415                 << "Using as default resource: '"
00416                 << fileName
00417                 << "'"
00418                 << endl;
00419 
00420       ResourceCalendar *defaultResource = new ResourceLocal( fileName );
00421       //defaultResource->setTimeZoneId);
00422       defaultResource->setResourceName( resourceName );
00423 
00424       manager->add( defaultResource );
00425       manager->setStandardResource( defaultResource );
00426     }
00427   }
00428 
00429   return true;
00430 }
KDE Logo
This file is part of the documentation for konsolekalendar Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 2 09:56:35 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003