kpilot Library API Documentation

pilotOrganizerEntry.cc

00001 /* pilotOrganizerEntry.cc                       KPilot
00002 **
00003 ** Copyright (c) 2002, Reinhold Kainhofer
00004 **
00005 ** This is a C++ wrapper for the Organizer entry structures.
00006 ** it is based on the pilotToDoEntry.cc by Dan Pilone,
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 ** MA 02111-1307, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to groot@kde.org
00028 */
00029 #include <stdlib.h>
00030 
00031 #include <pi-source.h>
00032 #include <pi-dlp.h>
00033 #include <pi-todo.h>
00034 
00035 #ifndef _KDEBUG_H_
00036 #include <kdebug.h>
00037 #endif
00038 
00039 #ifndef _KPILOT_OPTIONS_H
00040 #include "options.h"
00041 #endif
00042 
00043 #include "pilotOrganizerEntry.h"
00044 #include <calendar.h>
00045 
00046 using namespace KCal;
00047 
00048 
00049 static const char *pilotOrganizerEntry_id =
00050         "$Id: pilotOrganizerEntry.cc,v 1.2.4.1 2003/03/12 23:31:10 adridg Exp $";
00051 
00052 PilotOrganizerEntry::PilotOrganizerEntry(void):PilotAppCategory() {
00053         ::memset(&fData, 0, sizeof(OrganizerEntry));
00054 }
00055 
00056 
00057 PilotOrganizerEntry::PilotOrganizerEntry(PilotRecord * rec):PilotAppCategory(rec) {
00058 //      unpack( (unsigned char *) rec->getData(), rec->getLen());
00059         (void) pilotOrganizerEntry_id;
00060 }
00061 
00062 
00063 PilotOrganizerEntry::PilotOrganizerEntry(const PilotOrganizerEntry & e):PilotAppCategory(e) {
00064         ::memcpy(&fData, &e.fData, sizeof fData );
00065 }                               // end of copy constructor
00066 
00067 PilotOrganizerEntry::PilotOrganizerEntry(KCal::Todo*todo):PilotAppCategory() {
00068         // TODO: assign values
00069 }
00070 
00071 PilotOrganizerEntry& PilotOrganizerEntry::operator=(const KCal::Todo &todo) {
00072         // TODO: set this entry from the todo
00073 }
00074 KCal::Todo* PilotOrganizerEntry::getTodo(){
00075         KCal::Todo*todo=new KCal::Todo();
00076         // TODO: now set the todo entry from the this entry
00077 }
00078 
00079 
00080 PilotOrganizerEntry & PilotOrganizerEntry::operator = (const PilotOrganizerEntry & e) {
00081         if (this != &e) {
00082                 PilotAppCategory::operator =(e);
00083                 ::memcpy(&fData, &e.fData, sizeof(fData));
00084         }
00085         return *this;
00086 }                               // end of assignment operator
00087 
00088 void PilotOrganizerEntry::setDate(const po_date_type tp, unsigned short int d) {
00089         QTime tm;
00090         if (d == 0xffff) { QDate dt; fData.dates[tp].setDate(dt); fData.dates[tp].setTime(tm); return;}
00091         QDate dt( (d >> 9) + 4, ((d >> 5) & 15) - 1, d & 31);
00092                 // TODO: possible buffer overflow if tp>=4...
00093         fData.dates[tp].setDate(dt);
00094         fData.dates[tp].setTime(tm);
00095 };
00096 
00097 void PilotOrganizerEntry::setDescription(const char *desc) {
00098         KPILOT_FREE(fData.descr);
00099         if (desc) {
00100                 if (::strlen(desc) > 0) {
00101                         fData.descr = (char *)::malloc(::strlen(desc) + 1);
00102                         if (fData.descr) {
00103                                 ::strcpy(fData.descr, desc);
00104                         } else {
00105                                 kdError(LIBPILOTDB_AREA) << __FUNCTION__
00106                                         << ": malloc() failed, description not set"
00107                                         << endl;
00108                         }
00109                 } else fData.descr = 0L;
00110         }
00111         else {
00112                 fData.descr = 0L;
00113         }
00114 }
00115 
00116 void PilotOrganizerEntry::setNote(const char *note) {
00117         KPILOT_FREE(fData.note);
00118         if (note) {
00119                 if (::strlen(note) > 0) {
00120                         fData.note = (char *)::malloc(::strlen(note) + 1);
00121                         if (fData.note) {
00122                                 ::strcpy(fData.note, note);
00123                         } else {
00124                                 kdError(LIBPILOTDB_AREA) << __FUNCTION__
00125                                         << ": malloc() failed, note not set" << endl;
00126                         }
00127                 } else fData.note = 0;
00128         }
00129         else
00130         {
00131                 fData.note = 0L;
00132         }
00133 }
00134 
00135 void PilotOrganizerEntry::setCustStr(const char *note) {
00136         KPILOT_FREE(fData.customstr);
00137         if (note) {
00138                 if (::strlen(note) > 0) {
00139                         fData.customstr = (char *)::malloc(::strlen(note) + 1);
00140                         if (fData.customstr) {
00141                                 ::strcpy(fData.customstr, note);
00142                         } else {
00143                                 kdError(LIBPILOTDB_AREA) << __FUNCTION__
00144                                         << ": malloc() failed, note not set" << endl;
00145                         }
00146                 } else fData.customstr = 0;
00147         }
00148         else
00149         {
00150                 fData.customstr = 0L;
00151         }
00152 }
00153 
00154 void PilotOrganizerEntry::free_OrganizerEntry(OrganizerEntry*entry) {
00155         if (entry->descr) free(entry->descr);
00156         if (entry->note) free(entry->note);
00157         if (entry->customstr) free(entry->customstr);
00158 }
00159 
00160 
00161 
00162 // $Log: pilotOrganizerEntry.cc,v $
00163 // Revision 1.2.4.1  2003/03/12 23:31:10  adridg
00164 // CVS_SILENT: FSF address change
00165 //
00166 // Revision 1.2  2002/07/05 00:15:22  kainhofe
00167 // Added KPilotDeviceLink::tickle(), Changelog update, compile fixes
00168 //
00169 // Revision 1.1  2002/04/07 12:09:43  kainhofe
00170 // Initial checkin of the conduit. The gui works mostly, but syncing crashes KPilot...
00171 //
00172 // Revision 1.7  2002/04/07 11:56:19  reinhold
00173 // Last version before moving to KDE CVS
00174 //
00175 // Revision 1.6  2002/04/07 01:03:53  reinhold
00176 // the list of possible actions is now created dynamically
00177 //
00178 // Revision 1.5  2002/04/05 21:17:01  reinhold
00179 // *** empty log message ***
00180 //
00181 // Revision 1.4  2002/04/01 09:22:10  reinhold
00182 // Implemented the syncNextRecord routine
00183 //
00184 // Revision 1.3  2002/03/10 23:58:32  reinhold
00185 // Made the conduit compile...
00186 //
00187 // Revision 1.2  2002/03/10 16:06:43  reinhold
00188 // Cleaned up the class hierarchy, implemented some more features (should be quite finished now...)
00189 //
00190 // Revision 1.1.1.1  2002/03/09 15:38:45  reinhold
00191 // Initial checin of the  project manager / List manager conduit.
00192 //
00193 //
00194 //
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:14 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001