CCalendarDB Class Reference

This class contains core API's to interact with SQLite database. It will perform the query operations in the database. More...

#include <CCalendarDB.h>


Public Member Functions

int setAutocommitOff ()
int initDB ()
void setApplicationName (string appName)
sqlite3 * getDb ()
int insertRows (sqlite3_stmt *preparedStmt, int &iSqliteError)
bool updateDB (sqlite3_stmt *preparedStmt, int &iSqliteError)
void sqliteErrorMapper (int iSqliteError, int &pErrorCode)
bool rollbackDB ()
bool commitDB (string szMessage)
bool closeDB ()
QueryResult * getRecords (char *pQuery, int &iSqliteError)
bool sendDBusMessage (string szSendMessage)
bool initializeDBus ()
 ~CCalendarDB ()
void InstanceDestroy ()
int execSQL (const char *pQuery)

Static Public Member Functions

static CCalendarDBInstance ()

Private Member Functions

 CCalendarDB ()
 CCalendarDB (CCalendarDB &calendardb)
CCalendarDBoperator= (CCalendarDB &calendardb)
void sem_p (void)
void sem_v (void)
bool checkTimezoneTable ()
bool fillTimezoneTable (int &iSqliteError)
bool insertTimezoneInfo (string tzId, string location, time_t dtstartStd, time_t dtstartDst, int offsetStd, int offsetDst, int dstflag, string tzname, string rruleStd, string rruleDst)

Static Private Member Functions

static bool validateDbFile (const std::string &szDbFilename)
static bool moveToBackup (const std::string &szDbFilename)

Private Attributes

sqlite3 * pDb
DBusConnection * pBus
int sem_id

Static Private Attributes

static CCalendarDBpCalendarDb = 0


Detailed Description

This class contains core API's to interact with SQLite database. It will perform the query operations in the database.

CCalendarDB class


Constructor & Destructor Documentation

CCalendarDB::~CCalendarDB (  ) 

This is the default destructor for CCalendarDB class

CCalendarDB::CCalendarDB (  )  [private]

CCalendarDB

Parameters:
 None
Returns:
: None This function is constructor for CCalendarDB class and will be called when ever object of this class is created.
CCalendarDB
Parameters:
None 
Returns:
None This function is constructor for CCalendarDB class and will be called when ever object of this class is created.As CCalendarDB class is defined as singleton class constructor is declared as private member.

References pBus, and pDb.

CCalendarDB::CCalendarDB ( CCalendarDB calendardb  )  [private]

Dummy copy constructor


Member Function Documentation

int CCalendarDB::setAutocommitOff (  ) 

Parameters:
 none
Returns:
: int SUCCESS/FAILURE
Function to set the autocommit off in sqlite database.

References pDb, and rollbackDB().

Referenced by fillTimezoneTable(), and CMulticalendar::setAutocommitOff().

int CCalendarDB::initDB (  ) 

initDB

Parameters:
None 
Returns:
: int database intialization status This function Creates database file in ~/.calenadar/calenadrdb if it is not present. If DB file already exists then it opens the file for DB transactions. Also responsible for creation of all DB tables if they are not present in DB.
initDB
Parameters:
None 
Returns:
int database intialization status This r/share/applications/tsclient.desktop' unction Creates database file in ~/.calenadar/calenadrdb if it is not present. If DB file already exists then it opens the file for DB transactions. Also responsible for creation of all DB tables if they are not present in DB.

References checkTimezoneTable(), execSQL(), fillTimezoneTable(), getRecords(), moveToBackup(), pDb, and validateDbFile().

Referenced by Instance().

void CCalendarDB::setApplicationName ( string  appName  ) 

setApplicationName Function to set the application name of calling process

Parameters:
string Application name
Returns:
void

sqlite3 * CCalendarDB::getDb (  ) 

int CCalendarDB::insertRows ( sqlite3_stmt *  pPreparedStmt,
int &  iSqliteError 
)

insertRows

Parameters:
 preparedStmt: Pointer to prepared statement
 int& iSqliteError - place holder for error code from sqlite
Returns:
: int : Id of the inserted Row (so that functions at higher levels can make a note of ID added) This function returns ID of the new row inserted. Function is used to add new rows in all tables.(EVETN ,TODO and JOURNAL)
insertRows
Parameters:
preparedStmt,: Pointer to prepared statement
Returns:
(int) Id of the inserted Row (so that functions at higher levels can make a note of ID added) This function returns ID of the new row inserted. Function is used to add new rows in all tables.(EVETN ,TODO and JOURNAL)

References pDb.

Referenced by CCalendar::addAlarm(), CCalendar::addCacheEntry(), CMulticalendar::addCalendar(), CCalendar::addComponent(), CCalendar::addEventCompDetails(), CMulticalendar::addInstance(), CCalendar::addJournalCompDetails(), CCalendar::addMapTableInfo(), CCalendar::addParameters(), CCalendar::addRecurrence(), CCalendar::addTodoCompDetails(), CCalendar::addXProperties(), insertTimezoneInfo(), and CCalendar::updateTrash().

bool CCalendarDB::updateDB ( sqlite3_stmt *  pPreparedStmt,
int &  iSqliteError 
)

updateDB

Parameters:
 preparedStmt: Pointer to prepared statement
 int& iSqliteError - place holder for error code from sqlite
Returns:
: bool : status of the DB transaction Function is used to modify rows in all tables.(EVETN ,TODO and JOURNAL)
updateDB
Parameters:
(preparedStmt) Pointer to prepared statement
Returns:
(bool) status of the DB transaction Function is used to modify rows in all tables.(EVETN ,TODO and JOURNAL)

Referenced by CCalendar::addAlarm(), CCalendar::addComponent(), CMulticalendar::clearCalendar(), CCalendar::deleteBirthDay(), CMulticalendar::deleteBirthdaysForCalendar(), CCalendar::deleteCacheEntry(), CMulticalendar::deleteCalendar(), CCalendar::deleteEvent(), CCalendar::deleteJournal(), CCalendar::deleteTodo(), CMulticalendar::dropInstances(), CCalendar::modifyBirthDay(), CMulticalendar::modifyCalendar(), CCalendar::modifyEvent(), CCalendar::modifyJournal(), CCalendar::modifyRecurrence(), and CCalendar::modifyTodo().

void CCalendarDB::sqliteErrorMapper ( int  iSqliteError,
int &  pErrorCode 
)

sqliteErrorMapper

Parameters:
iSqliteError - error obtained from sqlite
pErrorCode - error message thrown to external world
Returns:
void
Function to Map sqlite error to external error

Referenced by CCalendar::addAlarm(), CCalendar::addBirthDay(), CCalendar::addCacheEntry(), CMulticalendar::addCalendar(), CCalendar::addComponent(), CCalendar::addEventCompDetails(), CMulticalendar::addInstance(), CCalendar::addJournalCompDetails(), CCalendar::addMapTableInfo(), CCalendar::addParameters(), CCalendar::addRecurrence(), CCalendar::addTodoCompDetails(), CCalendar::addXProperties(), CCalendar::checkDuplicateEntry(), CCalendar::checkEntryExist(), CMulticalendar::checkExistenceOfFutureRepeatingEvent(), CCalendar::checkFieldinTable(), CMulticalendar::checkForNextPrev(), CMulticalendar::clearCalendar(), CMulticalendar::deleteAllComponents(), CCalendar::deleteBirthDay(), CMulticalendar::deleteBirthdaysForCalendar(), CCalendar::deleteCacheEntry(), CMulticalendar::deleteCalendar(), CCalendar::deleteComponent(), CCalendar::deleteEvent(), CCalendar::deleteJournal(), CMulticalendar::deleteNonRecurrentComponents(), CCalendar::deleteTodo(), CCalendar::destroyExistingValidAlarms(), CMulticalendar::dropInstances(), CCalendar::getAllDeletedItems(), CCalendar::getAllEventsTodos(), CCalendar::getBirthDayEvent(), CCalendar::getCacheTableCount(), CMulticalendar::getCalendarIdForComponent(), CCalendar::getChangeIds(), CMulticalendar::getComponentCount(), CCalendar::getComponents(), CMulticalendar::getComponentsAllCalendars(), CMulticalendar::getComponentsWithLimitedData(), CCalendar::getCookie(), CMulticalendar::getCount(), CMulticalendar::getDateRange(), CCalendar::getEvent(), CMulticalendar::getEventInList(), CCalendar::getEvents(), CCalendar::getExternalToLocalId(), CCalendar::getIdList(), CMulticalendar::getInstanceNumber(), CCalendar::getJournal(), CCalendar::getJournals(), CMulticalendar::getLatestComponent(), CMulticalendar::getNumOfAllDayEventsForToday(), CMulticalendar::getNumOfUndoneTasks(), CMulticalendar::getPrevNextComponent(), CCalendar::getRecursiveEventsInRange(), CMulticalendar::getTodaysAllDay(), CCalendar::getTodo(), CCalendar::getTodos(), CMulticalendar::getVisibleCalendarCount(), CMulticalendar::giveExpiredEntries(), CMulticalendar::giveRecursiveExpiredEvents(), insertTimezoneInfo(), CMulticalendar::localBdayEventFromRemoteId(), CCalendar::modifyBirthDay(), CMulticalendar::modifyCalendar(), CCalendar::modifyEvent(), CCalendar::modifyJournal(), CCalendar::modifyRecurrence(), CCalendar::modifyTodo(), CCalendar::registerAlarmForVisibleCalendar(), CCalendar::updateTrash(), and CComponent::updateUntilInDB().

bool CCalendarDB::rollbackDB (  ) 

rollbackDB

Parameters:
 None
Returns:
: bool : status of the rollback operation Function is used to rollback in case of inconsistency in DB transaction?
rollbackDB
Parameters:
None 
Returns:
(bool) status of the rollback operation Function is used to rollback in case of inconsistency in DB transaction?

References pDb.

Referenced by commitDB(), CMulticalendar::rollbackAllChanges(), and setAutocommitOff().

bool CCalendarDB::commitDB ( string  szMessage  ) 

commitDB

Parameters:
 None
Returns:
: bool : status of the commit operation Function is used to commit DB transaction?
commitDB
Parameters:
None 
Returns:
(bool) status of the commit operation Function is used to commit DB transaction?

References pDb, rollbackDB(), and sendDBusMessage().

Referenced by CMulticalendar::commitAllChanges(), and fillTimezoneTable().

bool CCalendarDB::closeDB (  ) 

closeDB

Parameters:
 None
Returns:
: bool : status of the DB close Function is used to close DB file.
closeDB
Parameters:
None 
Returns:
(bool) status of the DB close Function is used to close DB file.

References pDb.

Referenced by CMulticalendar::~CMulticalendar().

QueryResult * CCalendarDB::getRecords ( char *  pQuery,
int &  iSqliteError 
)

getRecords

Parameters:
 query: sql statement in form of query.
 int& reference to error code.
Returns:
: QueryResult : result of query is obtained in QueryResult structure Function is used to get result from a query.
getRecords
Parameters:
(query) sql statement in form of query.
Returns:
(QueryResult) result of query is obtained in QueryResult structure Function is used to get result from a query.

References pDb.

Referenced by CCalendar::checkDuplicateEntry(), CCalendar::checkEntryExist(), CMulticalendar::checkExistenceOfFutureRepeatingEvent(), CCalendar::checkFieldinTable(), CMulticalendar::checkForNextPrev(), checkTimezoneTable(), CMulticalendar::deleteAllComponents(), CCalendar::deleteComponent(), CMulticalendar::deleteNonRecurrentComponents(), CCalendar::destroyExistingValidAlarms(), CComponent::getAlarmProperties(), CCalendar::getAllDeletedItems(), CCalendar::getAllEventsTodos(), CCalendar::getBirthDayEvent(), CCalendar::getCacheTableCount(), CMulticalendar::getCalendarById(), CMulticalendar::getCalendarIdForComponent(), CCalendar::getChangeIds(), CMulticalendar::getComponentCount(), CCalendar::getComponents(), CMulticalendar::getComponentsAllCalendars(), CMulticalendar::getComponentsWithLimitedData(), CCalendar::getCookie(), CMulticalendar::getCount(), CMulticalendar::getDateRange(), CCalendar::getEvent(), CMulticalendar::getEventInList(), CCalendar::getEvents(), CCalendar::getExternalToLocalId(), CCalendar::getIdList(), CMulticalendar::getInstanceNumber(), CCalendar::getJournal(), CCalendar::getJournals(), CMulticalendar::getLatestComponent(), CMulticalendar::getListCalFromMc(), CMulticalendar::getNumOfAllDayEventsForToday(), CMulticalendar::getNumOfUndoneTasks(), CComponentDetails::getParameter(), CMulticalendar::getPrevNextComponent(), CComponentDetails::getPropertyValues(), CComponent::getRecurrenceProperties(), CCalendar::getRecursiveEventsInRange(), CMulticalendar::getTodaysAllDay(), CCalendar::getTodo(), CCalendar::getTodos(), CMulticalendar::getVisibleCalendarCount(), CMulticalendar::giveExpiredEntries(), CMulticalendar::giveRecursiveExpiredEvents(), initDB(), CMulticalendar::localBdayEventFromRemoteId(), CCalendar::registerAlarmForVisibleCalendar(), CMulticalendar::restoreAlarms(), CComponentDetails::retrieveParameterDetails(), CComponentDetails::retrieveXPropertyDetails(), and CCalendar::updateTrash().

CCalendarDB * CCalendarDB::Instance (  )  [static]

Instance

Parameters:
 None
Returns:
: CCalendarDB* This function is used to create instance of CCalendarDB class, since CCalendarDB is declared as singleton class-(constructor is declared as private ) when ever object of this class needs to be created Instance is to be called.
Instance
Parameters:
None 
Returns:
CCalendarDB* This function is used to create instance of CCalendarDB class, since CCalendarDB is declared as singleton class-(constructor is declared as private ) when ever object of this class needs to be created Instance is to be called.

References getDb(), initDB(), and pCalendarDb.

Referenced by CCalendar::addAlarm(), CCalendar::addAttendeeDetails(), CCalendar::addBirthDay(), CCalendar::addCacheEntry(), CMulticalendar::addCalendar(), CCalendar::addComponent(), CCalendar::addEventCompDetails(), CMulticalendar::addInstance(), CCalendar::addJournalCompDetails(), CCalendar::addMapTableInfo(), CCalendar::addOrganizer(), CCalendar::addParameters(), CCalendar::addRecurrence(), CCalendar::addTodoCompDetails(), CCalendar::addXProperties(), CCalendar::checkDuplicateEntry(), CCalendar::checkEntryExist(), CMulticalendar::checkExistenceOfFutureRepeatingEvent(), CCalendar::checkFieldinTable(), CMulticalendar::checkForNextPrev(), CMulticalendar::clearCalendar(), CMulticalendar::commitAllChanges(), CMulticalendar::deleteAllComponents(), CCalendar::deleteBirthDay(), CMulticalendar::deleteBirthdaysForCalendar(), CCalendar::deleteCacheEntry(), CMulticalendar::deleteCalendar(), CCalendar::deleteComponent(), CMulticalendar::deleteComponents(), CCalendar::deleteEvent(), CCalendar::deleteJournal(), CMulticalendar::deleteNonRecurrentComponents(), CCalendar::deleteTodo(), CCalendar::destroyExistingValidAlarms(), CMulticalendar::dropInstances(), CMulticalendar::enableAutomaticDeletion(), CComponent::getAlarmProperties(), CCalendar::getAllDeletedItems(), CCalendar::getAllEventsTodos(), CCalendar::getBirthDayEvent(), CCalendar::getCacheTableCount(), CMulticalendar::getCalendarById(), CMulticalendar::getCalendarIdForComponent(), CCalendar::getChangeIds(), CMulticalendar::getComponentCount(), CCalendar::getComponents(), CMulticalendar::getComponentsAllCalendars(), CMulticalendar::getComponentsAllCalendarsBySummary(), CMulticalendar::getComponentsWithLimitedData(), CCalendar::getCookie(), CMulticalendar::getCount(), CMulticalendar::getDateRange(), CCalendar::getEvent(), CMulticalendar::getEventInList(), CCalendar::getEvents(), CCalendar::getExternalToLocalId(), CCalendar::getIdList(), CMulticalendar::getInstanceNumber(), CMulticalendar::getInstances(), CCalendar::getJournal(), CCalendar::getJournals(), CMulticalendar::getLatestComponent(), CMulticalendar::getListCalFromMc(), CMulticalendar::getNumOfAllDayEventsForToday(), CMulticalendar::getNumOfUndoneTasks(), CComponentDetails::getParameter(), CMulticalendar::getPrevNextComponent(), CComponentDetails::getPropertyValues(), CComponent::getRecurrenceProperties(), CCalendar::getRecursiveEventsInRange(), CMulticalendar::getTodaysAllDay(), CCalendar::getTodo(), CCalendar::getTodos(), CMulticalendar::getVisibleCalendarCount(), CMulticalendar::giveExpiredEntries(), CMulticalendar::giveRecursiveExpiredEvents(), CMulticalendar::localBdayEventFromRemoteId(), CCalendar::modifyBirthDay(), CMulticalendar::modifyCalendar(), CCalendar::modifyEvent(), CCalendar::modifyJournal(), CCalendar::modifyRecurrence(), CCalendar::modifyTodo(), CMulticalendar::regenerateInstances(), CCalendar::registerAlarmForVisibleCalendar(), CMulticalendar::restoreAlarms(), CComponentDetails::retrieveParameterDetails(), CComponentDetails::retrieveXPropertyDetails(), CMulticalendar::rollbackAllChanges(), CMulticalendar::setAutocommitOff(), CCalendar::updateTrash(), CComponent::updateUntilInDB(), and CMulticalendar::~CMulticalendar().

bool CCalendarDB::sendDBusMessage ( string  szSendMessage  ) 

sendDBusMessage Send the DBusMessage over the session bus

Parameters:
string Message to send
Returns:
TRUE/FALSE

References CMulticalendar::getApplicationName(), CMulticalendar::MCInstance(), and pBus.

Referenced by commitDB(), and CMulticalendar::deleteComponents().

int CCalendarDB::execSQL ( const char *  pQuery  ) 

execSQL

Parameters:
(pQquery) sql statement in form of query.
Returns:
SQL error code Function can be used in general SQL statements execution, i.e. for table creation

References getDb(), and pCalendarDb.

Referenced by CMulticalendar::clearCalendar(), fillTimezoneTable(), initDB(), CMulticalendar::regenerateInstances(), and CComponent::updateUntilInDB().

CCalendarDB & CCalendarDB::operator= ( CCalendarDB calendardb  )  [private]

Dummy assignment operator

bool CCalendarDB::validateDbFile ( const std::string &  szDbFilename  )  [static, private]

Validate and backup Database file if corrupted

Parameters:
szDbFilename filename if SQlite3 databsae storage file to check.
Returns:
TRUE if DB is found alive. FALSE if DB is treared as corrupted

Referenced by initDB().

bool CCalendarDB::moveToBackup ( const std::string &  szDbFilename  )  [static, private]

Make a backup copy of Database file

Parameters:
szDbFilename file to backup
Returns:
SUCCESS/FAILURE

Referenced by initDB().

bool CCalendarDB::checkTimezoneTable (  )  [private]

Check TIMEZONE table presence

Returns:
TRUE if TIMEZONE table exists and have some data

References getRecords().

Referenced by initDB().

bool CCalendarDB::fillTimezoneTable ( int &  iSqliteError  )  [private]

Fill TIMEZONE table using build-in timzone information

Parameters:
iSqliteError 
Returns:
SUCCESS/FAILURE

References commitDB(), execSQL(), insertTimezoneInfo(), and setAutocommitOff().

Referenced by initDB().

bool CCalendarDB::insertTimezoneInfo ( string  tzId,
string  location,
time_t  dtstartStd,
time_t  dtstartDst,
int  offsetStd,
int  offsetDst,
int  dstflag,
string  tzname,
string  rruleStd,
string  rruleDst 
) [private]

Add one timezone record into TIMEZONE table

Parameters:
tzId 
location 
dtstartStd 
dtstartDst 
offsetStd 
offsetDst 
dstflag 
tzname 
rruleStd 
rruleDst 
Returns:
SUCCESS/FAILURE

References getDb(), insertRows(), and sqliteErrorMapper().

Referenced by fillTimezoneTable().


Field Documentation

sqlite3* CCalendarDB::pDb [private]

DBusConnection* CCalendarDB::pBus [private]

DBus Connection pointer

Referenced by CCalendarDB(), and sendDBusMessage().

CCalendarDB * CCalendarDB::pCalendarDb = 0 [static, private]

Static CCalendarDB pointer for singleton usage

Initialising CCalendarDB global pointer to 0

Referenced by execSQL(), and Instance().


The documentation for this class was generated from the following files:

Generated on Tue Jul 27 14:17:50 2010 for calendar-backend by  doxygen 1.5.6