/**
  * Import remote calendar into Silverpeas calendar (update event if necessary)
  *
  * @param urlCalendar
  * @param localCalendar
  * @param loginICalendar
  * @param pwdIcalendar
  * @return ReturnCode
  */
 public String synchroIcalAgenda(
     URL urlCalendar, File localCalendar, String loginICalendar, String pwdIcalendar) {
   String returnCodeSynchro = AgendaSessionController.SYNCHRO_FAILED;
   try {
     // Private iCal URL
     // Use the SyncEngine.listCalendars() method to get URLs
     URL remoteCalendar = urlCalendar;
     // Creates a synchronizer engine
     SyncEngine engine = new SyncEngine();
     // Do the synchronization :
     // Remote SilverpeasCalendar -> localfile SilverpeasCalendar
     String remoteConnect =
         engine.synchronize(localCalendar, remoteCalendar, loginICalendar, pwdIcalendar);
     if (SyncEngine.REMOTE_CONNECT_SUCCEEDED.equals(remoteConnect)) {
       // localfile -> Silverpeas Agenda
       ImportIcalManager impIcalManager = new ImportIcalManager(agendaSessionController);
       String returnImport = impIcalManager.importIcalAgenda(localCalendar);
       if (returnImport.equals(AgendaSessionController.IMPORT_FAILED)) {
         returnCodeSynchro = AgendaSessionController.SYNCHRO_FAILED;
       } else {
         returnCodeSynchro = AgendaSessionController.SYNCHRO_SUCCEEDED;
       }
     } else {
       returnCodeSynchro = remoteConnect;
     }
   } catch (Exception e) {
     SilverTrace.error(
         "agenda", "SynchroIcalManager.synchroIcalAgenda()", "", e.fillInStackTrace());
   }
   return returnCodeSynchro;
 }
Exemple #2
0
 public boolean setStatusListener(ISyncStatusListener listener) {
   m_statusListener = listener;
   if (m_oSyncEngine != null) {
     m_oSyncEngine.getNotify().setSyncStatusListener(listener);
     return true;
   }
   return false;
 }
Exemple #3
0
  public void Destroy() {
    m_oSyncEngine.exitSync();
    stop(SYNC_WAIT_BEFOREKILL_SECONDS);

    if (ClientRegister.getInstance() != null) ClientRegister.getInstance().Destroy();

    DBAdapter.closeAll();

    m_pInstance = null;
  }
Exemple #4
0
  SyncThread(RhoClassFactory factory) throws Exception {
    super(factory);
    ThreadQueue.setLogCategory(LOG.getLogCategory());

    if (RhoConf.getInstance().isExist("sync_poll_interval"))
      setPollInterval(RhoConf.getInstance().getInt("sync_poll_interval"));

    m_oSyncEngine = new SyncEngine();
    m_oSyncEngine.setFactory(factory);

    m_oSyncEngine.setFactory(factory);

    LOG.INFO("sync_poll_interval: " + RhoConf.getInstance().getInt("sync_poll_interval"));
    LOG.INFO("syncserver: " + RhoConf.getInstance().getString("syncserver"));
    LOG.INFO("bulksync_state: " + RhoConf.getInstance().getInt("bulksync_state"));

    ClientRegister.Create(factory);

    if (RhoConf.getInstance().getString("syncserver").length() > 0) start(epLow);
  }
Exemple #5
0
  public void processCommand(IQueueCommand pCmd) {
    SyncCommand oSyncCmd = (SyncCommand) pCmd;
    switch (oSyncCmd.m_nCmdCode) {
      case scSyncAll:
        checkShowStatus(oSyncCmd);
        m_oSyncEngine.doSyncAllSources();
        break;
      case scSyncOne:
        {
          checkShowStatus(oSyncCmd);
          m_oSyncEngine.doSyncSource(
              new SyncEngine.SourceID(oSyncCmd.m_nCmdParam, oSyncCmd.m_strCmdParam));
        }
        break;

      case scSearchOne:
        {
          checkShowStatus(oSyncCmd);
          m_oSyncEngine.doSearch(
              ((SyncSearchCommand) oSyncCmd).m_arSources,
              oSyncCmd.m_strCmdParam,
              ((SyncSearchCommand) oSyncCmd).m_strFrom,
              ((SyncSearchCommand) oSyncCmd).m_bSyncChanges,
              oSyncCmd.m_nCmdParam);
        }
        break;

      case scLogin:
        {
          SyncLoginCommand oLoginCmd = (SyncLoginCommand) oSyncCmd;
          checkShowStatus(oSyncCmd);
          m_oSyncEngine.login(oLoginCmd.m_strName, oLoginCmd.m_strPassword, oLoginCmd.m_pNotify);
        }
        break;
    }
  }
Exemple #6
0
 void checkShowStatus(SyncCommand oSyncCmd) {
   boolean bShowStatus = oSyncCmd.m_bShowStatus && !this.isNoThreadedMode();
   m_oSyncEngine.getNotify().enableReporting(bShowStatus);
   if (m_oSyncEngine.getNotify().isReportingEnabled())
     m_statusListener.createStatusPopup(RhoAppAdapter.getMessageText("syncronizing_data"));
 }