Example #1
0
        private void OnSyncIntervalChanged(object o, EventArgs args)
        {
            if ((currentSyncUnit == SyncUnit.Seconds) && (SyncSpinButton.Value < 5))
            {
                if (oneMinuteLimitNotifyWindow != null)
                {
                    oneMinuteLimitNotifyWindow.Hide();
                    oneMinuteLimitNotifyWindow.Destroy();
                    oneMinuteLimitNotifyWindow = null;
                }
                SyncSpinButton.Value       = 5;
                oneMinuteLimitNotifyWindow =
                    new NotifyWindow(
                        SyncSpinButton, Util.GS("Synchronization Interval Limit"),
                        Util.GS("The synchronization interval cannot be set to less than 5 Seconds.  It will automatically change to 5 seconds."), Gtk.MessageType.Info, 10000);
                oneMinuteLimitNotifyWindow.ShowAll();
            }

            int syncSpinValue =
                CalculateActualSyncInterval((int)SyncSpinButton.Value,
                                            currentSyncUnit);

            try
            {
                lastSyncInterval = syncSpinValue;
                if (lastSyncInterval <= 0)
                {
                    ifws.SetDefaultSyncInterval(-1);
                }
                else
                {
                    ifws.SetDefaultSyncInterval(lastSyncInterval);
                }
            }
            catch (Exception e)
            {
                iFolderExceptionDialog ied = new iFolderExceptionDialog(
                    topLevelWindow, e);
                ied.Run();
                ied.Hide();
                ied.Destroy();
                return;
            }
        }
 private void OnSyncUnitsChanged(object o, EventArgs args)
 {
     if (oneMinuteLimitNotifyWindow != null)
        {
     oneMinuteLimitNotifyWindow.Hide();
     oneMinuteLimitNotifyWindow.Destroy();
     oneMinuteLimitNotifyWindow = null;
        }
        int syncSpinValue = (int)SyncSpinButton.Value;
        currentSyncUnit = (SyncUnit)SyncUnitsComboBox.Active;
        if (currentSyncUnit == SyncUnit.Seconds)
        {
     SyncSpinButton.Adjustment.Lower = 60;
     if (syncSpinValue < 60)
     {
      oneMinuteLimitNotifyWindow =
       new NotifyWindow(
       SyncSpinButton, Util.GS("Synchronization Interval Limit"),
       Util.GS("The synchronization interval cannot be set to less than one minute.  It was automatically changed to 60 seconds."),
       Gtk.MessageType.Info, 10000);
      oneMinuteLimitNotifyWindow.ShowAll();
      SyncSpinButton.ValueChanged -=
       new EventHandler(OnSyncIntervalChanged);
      SyncSpinButton.Value = 60;
      syncSpinValue = 60;
      SyncSpinButton.ValueChanged +=
       new EventHandler(OnSyncIntervalChanged);
     }
        }
        else
        {
     SyncSpinButton.Adjustment.Lower = 1;
        }
        int syncInterval =
     CalculateActualSyncInterval(syncSpinValue,
        currentSyncUnit);
        try
        {
     lastSyncInterval = syncInterval;
     if(lastSyncInterval <= 0)
     {
      ifws.SetDefaultSyncInterval(-1);
     }
     else
     {
      ifws.SetDefaultSyncInterval(lastSyncInterval);
     }
     SaveSyncUnitConfig();
        }
        catch(Exception e)
        {
     iFolderExceptionDialog ied = new iFolderExceptionDialog(
      topLevelWindow, e);
     ied.Run();
     ied.Hide();
     ied.Destroy();
     return;
        }
 }
 private void OniFolderUserAddedEvent(object o,
  iFolderUserAddedEventArgs args)
 {
     if (args == null || args.iFolderID == null || args.iFolderUser == null)
     return;
        if((bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_USERS))
        {
     string username;
     iFolderHolder ifHolder = ifdata.GetiFolder(args.iFolderID);
     if( (args.iFolderUser.FN != null) &&
      (args.iFolderUser.FN.Length > 0) )
      username = args.iFolderUser.FN;
     else
      username = args.iFolderUser.Name;
     NotifyWindow notifyWin = new NotifyWindow(
      tIcon, Util.GS("New iFolder User"),
      string.Format(Util.GS("{0} has joined the iFolder \"{1}\""), username, ifHolder.iFolder.Name),
      Gtk.MessageType.Info, 10000);
     notifyWin.LinkClicked +=
      new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
     notifyWin.ShowAll();
        }
 }
 private void OniFolderSyncEvent(object o, CollectionSyncEventArgs args)
 {
     if (args == null || args.ID == null || args.Name == null)
     return;
        switch(args.Action)
        {
     case Simias.Client.Event.Action.StartSync:
     {
      collectionSynchronizing = args.ID;
      break;
     }
     case Simias.Client.Event.Action.StopSync:
     {
      currentIconAnimationDirection = 0;
       if (collectionSynchronizing != null)
       {
        iFolderHolder ifHolder = ifdata.GetiFolder(collectionSynchronizing);
        if (ifHolder != null)
        {
     if (synchronizationErrors.ContainsKey(ifHolder.iFolder.ID))
     {
      Hashtable collectionSyncErrors = (Hashtable)synchronizationErrors[ifHolder.iFolder.ID];
      ICollection errors = collectionSyncErrors.Keys;
      Debug.PrintLine(String.Format("Number of errors: {0}", errors.Count));
      ArrayList keysToClear = new ArrayList();
      bool showErrorBaloon = false;
      bool showGenericBaloon = true;
      foreach(SyncStatus syncStatusKey in errors)
      {
       string errMsg = (string) collectionSyncErrors[syncStatusKey];
       if (errMsg != null && errMsg.Length > 0)
       {
     showErrorBaloon = true;
     NotifyWindow notifyWin = new NotifyWindow(
     tIcon, string.Format(Util.GS("Incomplete Synchronization: {0}"), ifHolder.iFolder.Name),
     errMsg,
     Gtk.MessageType.Warning, 5000);
     notifyWin.LinkClicked +=
     new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
     notifyWin.ShowAll();
     showGenericBaloon = false;
     keysToClear.Add(syncStatusKey);
       }
      }
      if( showErrorBaloon == true)
      {
       if( showGenericBaloon )
       {
        NotifyWindow notifyWin = new NotifyWindow(
        tIcon, string.Format(Util.GS("Incomplete Synchronization: {0}"), ifHolder.iFolder.Name),
        Util.GS("Synchronization log contains the information regarding the files that are not synchronized"),
        Gtk.MessageType.Warning, 5000);
        notifyWin.LinkClicked +=
        new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
        notifyWin.ShowAll();
       }
      }
      foreach(SyncStatus syncStatusKey in keysToClear)
      {
       collectionSyncErrors.Remove( syncStatusKey);
      }
      Debug.PrintLine(String.Format("After removing keys count: {0}", collectionSyncErrors.Count));
     }
        }
       }
      collectionSynchronizing = null;
      break;
     }
        }
        gAppIcon.Pixbuf = RunningPixbuf;
 }
 private void OniFolderAddedEvent(object o, iFolderAddedEventArgs args)
 {
     if (args == null || args.iFolderID == null)
     return;
        iFolderHolder ifHolder = ifdata.GetiFolder(args.iFolderID);
        if (ifHolder == null)
     return;
        if (ifHolder.iFolder == null)
     return;
        if(!ifdata.IsCurrentUser(ifHolder.iFolder.OwnerID))
        {
     if(ifHolder.iFolder.IsSubscription &&
      ((bool)ClientConfig.Get(ClientConfig.KEY_NOTIFY_IFOLDERS)))
     {
      NotifyWindow notifyWin = new NotifyWindow(
        tIcon,
        string.Format(Util.GS("New iFolder \"{0}\""),
     ifHolder.iFolder.Name),
        string.Format(Util.GS("{0} has invited you to participate in this shared iFolder.\n\nClick <a href=\"SetUpiFolder:{1}\">here</a> to set up this iFolder."),
     ifHolder.iFolder.Owner, ifHolder.iFolder.CollectionID),
        Gtk.MessageType.Info, 10000);
      notifyWin.LinkClicked +=
       new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
      notifyWin.ShowAll();
     }
        }
 }
 private void trayapp_clicked(object obj, ButtonPressEventArgs args)
 {
     if (CurrentState == iFolderAppState.Starting)
        {
     if (startingUpNotifyWindow == null)
     {
      startingUpNotifyWindow = new NotifyWindow(
       tIcon, Util.GS("iFolder is starting"),
       Util.GS("Please wait for iFolder to start...\n\nPress <a href=\"CancelStartup\">here</a> to cancel."),
       Gtk.MessageType.Info, 0);
      startingUpNotifyWindow.LinkClicked +=
       new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
      startingUpNotifyWindow.Hidden +=
       new EventHandler(OnStartingUpNotifyWindowHidden);
      startingUpNotifyWindow.ShowAll();
     }
     return;
        }
        else if (CurrentState == iFolderAppState.Stopping)
        {
     if (shuttingDownNotifyWindow == null)
     {
      shuttingDownNotifyWindow = new NotifyWindow(
       tIcon, Util.GS("iFolder is shutting down"),
       "",
       Gtk.MessageType.Info, 0);
      shuttingDownNotifyWindow.Hidden +=
       new EventHandler(OnShuttingDownNotifyWindowHidden);
      shuttingDownNotifyWindow.ShowAll();
     }
     return;
        }
        if (Util.CurrentModalWindow != null)
        {
     try
     {
      Util.CurrentModalWindow.Present();
      return;
     }
     catch{}
        }
        switch(args.Event.Button)
        {
     case 1:
      DomainInformation[] domains = domainController.GetDomains();
      if (domains.Length < 1)
      {
       ShowAddAccountWizard();
      }
      else
      {
       iFolderWindow ifwin = Util.GetiFolderWindow();
       if (ifwin == null || !ifwin.IsActive)
        Util.ShowiFolderWindow();
       else
        ifwin.CloseWindow();
      }
      break;
     case 2:
      break;
     case 3:
      show_tray_menu();
      break;
        }
 }
 private void OnSyncIntervalChanged(object o, EventArgs args)
 {
     if ((currentSyncUnit == SyncUnit.Seconds) && (SyncSpinButton.Value < 5) )
        {
        if (oneMinuteLimitNotifyWindow != null)
        {
       oneMinuteLimitNotifyWindow.Hide();
        oneMinuteLimitNotifyWindow.Destroy();
        oneMinuteLimitNotifyWindow = null;
        }
        SyncSpinButton.Value = 5;
        oneMinuteLimitNotifyWindow =
      new NotifyWindow(
       SyncSpinButton, Util.GS("Synchronization Interval Limit"),
       Util.GS("The synchronization interval cannot be set to less than 5 Seconds.  It will automatically change to 5 seconds."), Gtk.MessageType.Info, 10000);
       oneMinuteLimitNotifyWindow.ShowAll();
        }
        int syncSpinValue =
     CalculateActualSyncInterval((int)SyncSpinButton.Value,
        currentSyncUnit);
        try
        {
     lastSyncInterval = syncSpinValue;
     if(lastSyncInterval <= 0)
     {
      ifws.SetDefaultSyncInterval(-1);
     }
     else
     {
      ifws.SetDefaultSyncInterval(lastSyncInterval);
     }
        }
        catch(Exception e)
        {
     iFolderExceptionDialog ied = new iFolderExceptionDialog(
      topLevelWindow, e);
     ied.Run();
     ied.Hide();
     ied.Destroy();
     return;
        }
 }
 private void trayapp_clicked(object obj, ButtonPressEventArgs args)
 {
     if (CurrentState == iFolderState.Starting)
        {
     if (startingUpNotifyWindow == null)
     {
      startingUpNotifyWindow = new NotifyWindow(
       tIcon, Util.GS("iFolder is starting"),
       Util.GS("Please wait for iFolder to start...\n\nPress <a href=\"CancelStartup\">here</a> to cancel."),
       Gtk.MessageType.Info, 0);
      startingUpNotifyWindow.LinkClicked +=
       new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
      startingUpNotifyWindow.ShowAll();
     }
     return;
        }
        else if (CurrentState == iFolderState.Stopping)
        {
     if (shuttingDownNotifyWindow == null)
     {
      shuttingDownNotifyWindow = new NotifyWindow(
       tIcon, Util.GS("iFolder is shutting down"),
       Util.GS("Press <a href=\"ForceShutdown\">here</a> to force iFolder to shut down now."),
       Gtk.MessageType.Info, 0);
      shuttingDownNotifyWindow.LinkClicked +=
       new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
      shuttingDownNotifyWindow.ShowAll();
     }
     return;
        }
        if (Util.CurrentModalWindow != null)
        {
     Console.WriteLine("Modal present");
     try
     {
      Util.CurrentModalWindow.Present();
      return;
     }
     catch{}
        }
        switch(args.Event.Button)
        {
     case 1:
      iFolderWindow ifwin = Util.GetiFolderWindow();
      if (ifwin == null || !ifwin.IsActive)
       Util.ShowiFolderWindow();
      else
       ifwin.Hide();
      break;
     case 2:
      break;
     case 3:
      show_tray_menu();
      break;
        }
 }
 private void OniFolderSyncEvent(object o, CollectionSyncEventArgs args)
 {
     if (args == null || args.ID == null || args.Name == null)
     return;
        switch(args.Action)
        {
     case Simias.Client.Event.Action.StartSync:
     {
      bCollectionIsSynchronizing = true;
      collectionSynchronizing = args.ID;
      break;
     }
     case Simias.Client.Event.Action.StopSync:
     {
      bCollectionIsSynchronizing = false;
      currentIconAnimationDirection = 0;
      gAppIcon.Pixbuf = RunningPixbuf;
       if (collectionSynchronizing != null)
       {
        iFolderHolder ifHolder = ifdata.GetiFolder(collectionSynchronizing);
        if (ifHolder != null)
        {
     if (synchronizationErrors.ContainsKey(ifHolder.iFolder.ID))
     {
      Hashtable collectionSyncErrors = (Hashtable)synchronizationErrors[ifHolder.iFolder.ID];
      ICollection errors = collectionSyncErrors.Keys;
      ArrayList keysToClear = new ArrayList();
      foreach(SyncStatus syncStatusKey in errors)
      {
       string errMsg = (string) collectionSyncErrors[syncStatusKey];
       if (errMsg != null && errMsg.Length > 0)
       {
        NotifyWindow notifyWin = new NotifyWindow(
     tIcon, string.Format(Util.GS("Incomplete Synchronization: {0}"), ifHolder.iFolder.Name),
     errMsg,
     Gtk.MessageType.Warning, 10000);
        notifyWin.LinkClicked +=
     new LinkClickedEventHandler(OnNotifyWindowLinkClicked);
        notifyWin.ShowAll();
        keysToClear.Add(syncStatusKey);
       }
      }
      foreach(SyncStatus syncStatusKey in keysToClear)
      {
       collectionSyncErrors[syncStatusKey] = "";
      }
     }
        }
       }
      collectionSynchronizing = null;
      break;
     }
        }
        try
        {
     iFolderWindow ifwin = Util.GetiFolderWindow();
     if(ifwin != null)
      ifwin.HandleSyncEvent(args);
     LogWindow logwin = Util.GetLogWindow(simiasManager);
     if(logwin != null)
      logwin.HandleSyncEvent(args);
        }
        catch {}
 }