Beispiel #1
0
CSQLiteAddressbookPlugin::CSQLiteAddressbookPlugin(IPluginRegistry *pApp)
  : m_pApplication(pApp)
{
  TDbFiles dbFiles;
  SQLITEPREFS::init();
  SQLITEPREFS::getDbFiles(dbFiles);
  if (dbFiles.empty()) {
    // Initial case after update from old version or new installation
    std::string strDBFN = GetGlobalPrefs()->getProfileFileName("pbook", "db");
    CSQLiteAddressbook *pBook =
        new CSQLiteAddressbook(pluginUUID, wxT("SQLite"), strDBFN);
    m_Addressbooks.push_back(pBook);
    m_pApplication->registerModule(pBook);
    saveAddressbookInfo();
  }
  else {
    // Otherwise, we have information in the registry
    TDbFiles::const_iterator it = dbFiles.begin();
    for (; it != dbFiles.end(); ++it) {
      CSQLiteAddressbook *pBook =
          new CSQLiteAddressbook(pluginUUID, it->first, it->second);
      m_Addressbooks.push_back(pBook);
      m_pApplication->registerModule(pBook);
    }
  }
}
NS_IMETHODIMP nsMailDatabase::GetSummaryValid(PRBool *aResult)
{
  NS_ENSURE_ARG_POINTER(aResult);
  PRUint32 folderSize;
  PRUint32  folderDate;
  PRUint32  actualFolderTimeStamp;
  PRInt32 numUnreadMessages;
  nsAutoString errorMsg;

        
  *aResult = PR_FALSE;
  
  if (m_folderFile && m_dbFolderInfo)
  {
    actualFolderTimeStamp = GetMailboxModDate();
  
    m_dbFolderInfo->GetNumUnreadMessages(&numUnreadMessages);
    m_dbFolderInfo->GetFolderSize(&folderSize);
    m_dbFolderInfo->GetFolderDate(&folderDate);

    // compare current version of db versus filed out version info, 
    // and file size in db vs file size on disk.
    PRUint32 version;

    m_dbFolderInfo->GetVersion(&version);
    nsCOMPtr <nsIFile> copyFolderFile;
    // clone file because nsLocalFile caches sizes.
    nsresult rv = m_folderFile->Clone(getter_AddRefs(copyFolderFile));
    NS_ENSURE_SUCCESS(rv, rv);
    PRInt64 fileSize;
    copyFolderFile->GetFileSize(&fileSize);
    if (folderSize == fileSize &&
        numUnreadMessages >= 0 && GetCurVersion() == version)
    {
      GetGlobalPrefs();
      // if those values are ok, check time stamp
      if (gTimeStampLeeway == 0)
        *aResult = folderDate == actualFolderTimeStamp;
      else
        *aResult = PR_ABS((PRInt32) (actualFolderTimeStamp - folderDate)) <= gTimeStampLeeway;
#ifndef PUTUP_ALERT_ON_INVALID_DB
    }
  }
#else
      if (!*aResult)
      {
        errorMsg.AppendLiteral("time stamp didn't match delta = ");
        errorMsg.AppendInt(actualFolderTimeStamp - folderDate);
        errorMsg.AppendLiteral(" leeway = ");
        errorMsg.AppendInt(gTimeStampLeeway);
      }
    }
Beispiel #3
0
bool CMainApp::OnInit()
{
  m_pSingleInstance = new wxSingleInstanceChecker(wxT("c'mon"));
  if (m_pSingleInstance->IsAnotherRunning()) {
    delete m_pSingleInstance;
    return false;
  }

  // Check wether user dir exists
  wxFileName fn;
  fn.Assign(wxStandardPaths::Get().GetUserLocalDataDir(), wxT("cmon"), wxEmptyString);
  if (!fn.DirExists()) {
    fn.Mkdir();
  }

  // Initialize Log
  wxLog::SetActiveTarget(new
      CFileLog(CGlobalPreferences::getLogFileName(), 1024*1024, 5));

  // Initialize the locale catalogs we'll be using
  wxLocale::AddCatalogLookupPathPrefix(".");
  m_Locale.Init(wxLANGUAGE_DEFAULT);
  m_Locale.AddCatalog("wxstd");
  m_Locale.AddCatalog("hzshared");
  m_Locale.AddCatalog("gui");

  // Initialize all GUI resources (fonts, bitmaps, etc.)
  wxInitAllImageHandlers();
  RESOURCES::init();

  // Load preferences from registry
  m_pPrefs = GetGlobalPrefs();

  // Load plug-in DLLs
  m_pPluginLoader = new CPluginLoader();
  m_pPluginLoader->init();

  // Init Sockets
  wxSocketBase::Initialize();

  // Create/Open database
  m_pDB = new CDBBackend(m_pPrefs->getDBFileName());
  if (!m_pDB->isOk()) {
    wxMessageBox(wxString::FromUTF8(m_pDB->getLastError().c_str()),
        wxMessageBoxCaptionStr, wxICON_ERROR|wxOK);
  }
  // Create Journal model
  m_pJournalModel = new CJournalModel(m_pDB);
  // Restore resolvers
  m_pResolverModel = new CResolverModel(m_pDB);

  // Resync Resolvers
  const TAddressbookMap& books = m_pPluginLoader->getAddressbooks();
  TAddressbookMap::const_iterator bit = books.begin();
  for (; bit != books.end(); ++bit) {
    if (!m_pResolverModel->hasEntry((*bit).second->getName())) {
      CAddressBookResolver *pR = new CAddressBookResolver((*bit).second);
      pR->setName((*bit).second->getName());
      pR->enable();
      m_pResolverModel->prependEntry(pR);
    }
  }

  // Create main application window
  m_pFrame = new CMainFrame();

  // Create call notification system
  m_pNotificationMgr = new CNotificationMgr(this);
  // Register for call monitor notifications
  const TCallMonitorMap& cms = m_pPluginLoader->getCallMonitors();
  TCallMonitorMap::const_iterator cit = cms.begin();
  for (; cit != cms.end(); ++cit) {
    (*cit).second->registerCallObserver(this);
  }
  // Finally show main window
  if (!m_pPrefs->getPrefs().startHidden()) {
    m_pFrame->Show();
  }
  SetTopWindow(m_pFrame);

  return true;
}