Exemple #1
0
        /// <summary>
        /// Set the Values in the Widgets
        /// </summary>
        private void PopulateWidgets()
        {
            //------------------------------
            // Set up all of the default values
            //------------------------------
            if ((bool)ClientConfig.Get(ClientConfig.KEY_SHOW_CREATION))
            {
                ShowConfirmationButton.Active = true;
            }
            else
            {
                ShowConfirmationButton.Active = false;
            }

            if ((bool)ClientConfig.Get(ClientConfig.KEY_SHOW_SYNC_LOG))
            {
                HideSyncLogButton.Active = true;
            }
            else
            {
                HideSyncLogButton.Active = false;
            }

            if ((bool)ClientConfig.Get(ClientConfig.KEY_IFOLDER_WINDOW_HIDE))
            {
                HideMainWindowButton.Active = true;
            }
            else
            {
                HideMainWindowButton.Active = false;
            }

            try
            {
                lastSyncInterval = ifws.GetDefaultSyncInterval();
                if (lastSyncInterval <= 0)
                {
                    SyncSpinButton.Value = 0;
                }
                else
                {
                    string syncUnitString = (string)
                                            ClientConfig.Get(ClientConfig.KEY_SYNC_UNIT);
                    switch (syncUnitString)
                    {
                    case "Seconds":
                        currentSyncUnit          = SyncUnit.Seconds;
                        SyncUnitsComboBox.Active = (int)SyncUnit.Seconds;

                        // Prevent the user from setting a sync interval less than
                        // five seconds.
                        SyncSpinButton.Adjustment.Lower = 1;
                        break;

                    case "Minutes":
                        currentSyncUnit          = SyncUnit.Minutes;
                        SyncUnitsComboBox.Active = (int)SyncUnit.Minutes;
                        break;

                    case "Hours":
                        currentSyncUnit          = SyncUnit.Hours;
                        SyncUnitsComboBox.Active = (int)SyncUnit.Hours;
                        break;

                    case "Days":
                        currentSyncUnit          = SyncUnit.Days;
                        SyncUnitsComboBox.Active = (int)SyncUnit.Days;
                        break;

                    default:
                        break;
                    }

                    SyncSpinButton.Value = CalculateSyncSpinValue(lastSyncInterval, currentSyncUnit);
                }
            }
            catch (Exception)
            {
                lastSyncInterval     = -1;
                SyncSpinButton.Value = 0;
            }

            if (lastSyncInterval <= 0)
            {
                AutoSyncCheckButton.Active  = false;
                SyncSpinButton.Sensitive    = false;
                SyncUnitsComboBox.Sensitive = false;
            }
            else
            {
                AutoSyncCheckButton.Active  = true;
                SyncSpinButton.Sensitive    = true;
                SyncUnitsComboBox.Sensitive = true;
            }

            AutoSyncCheckButton.Toggled += new EventHandler(OnAutoSyncButton);
            SyncSpinButton.ValueChanged +=
                new EventHandler(OnSyncIntervalChanged);
            SyncUnitsComboBox.Changed +=
                new EventHandler(OnSyncUnitsChanged);
        }
        /// <summary>
        /// Update iFolder
        /// </summary>
        /// <param name="ifolder">iFolderWeb Object</param>
        public void UpdateiFolder(iFolderWeb ifolder)
        {
            DomainController domainController = DomainController.GetDomainController();

            this.domain = domainController.GetDomain(ifolder.DomainID);

            this.ifolder = ifolder;

            if (ifolder.LastSyncTime == null || ifolder.LastSyncTime == "")
            {
                LastSuccessfulSync.Text = Util.GS("N/A");
            }
            else
            {
                LastSuccessfulSync.Text = ifolder.LastSyncTime;
            }
            FFSyncValue.Text = Util.GS("0");

            int syncInterval = 0;

            if (ifolder.EffectiveSyncInterval <= 0)
            {
                try
                {
                    syncInterval = ifws.GetDefaultSyncInterval();
                }
                catch
                {}
            }
            else
            {
                syncInterval = ifolder.EffectiveSyncInterval;
            }

            // Make sure it's shown in minutes
            if (syncInterval > 0)
            {
                syncInterval = syncInterval / 60;
            }

            SyncIntervalValue.Text = syncInterval + " " + Util.GS("minute(s)");

            string ifolderName = null, ifolderLocation = null;

            ifolderName     = ifolder.Name;
            ifolderLocation = ifolder.UnManagedPath;
            if (ifolder.Name.Length > displayName)
            {
                ifolderName = ifolder.Name.Substring(0, displayName) + "...";
            }
            if (ifolder.UnManagedPath.Length > displayableLocation)
            {
                ifolderLocation = ifolder.UnManagedPath.Substring(0, displayableLocation) + "...";
            }



            NameLabel.Markup     = string.Format("{0}", GLib.Markup.EscapeText(ifolderName));
            OwnerLabel.Markup    = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(ifolder.Owner));
            LocationLabel.Markup = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(ifolderLocation));
            AccountLabel.Markup  = string.Format("<span size=\"small\">{0}</span>", GLib.Markup.EscapeText(domain.Name));

            try
            {
                SyncSize ss = ifws.CalculateSyncSize(ifolder.ID);
                FFSyncValue.Text = string.Format("{0}", ss.SyncNodeCount);
            }
            catch (Exception)
            {
                FFSyncValue.Text = Util.GS("N/A");

//				iFolderExceptionDialog ied = new iFolderExceptionDialog(
//													topLevelWindow, e);
//				ied.Run();
//				ied.Hide();
//				ied.Destroy();
            }


            try
            {
                ds = ifws.GetiFolderDiskSpace(ifolder.ID);
            }
            catch (Exception)
            {
                ds = null;
//				iFolderExceptionDialog ied = new iFolderExceptionDialog(
//													topLevelWindow, e);
//				ied.Run();
//				ied.Hide();
//				ied.Destroy();
            }

            // check for iFolder Owner

/*			if(ifolder.CurrentUserID == ifolder.OwnerID)
 *                      {
 *                              if(LimitCheckButton == null)
 *                              {
 *                                      LimitCheckButton =
 *                                              new CheckButton(Util.GS("Set _Quota:"));
 *                                      LimitCheckButton.Toggled +=
 *                                                              new EventHandler(OnLimitSizeButton);
 *                                      diskTable.Attach(LimitCheckButton, 0,1,1,2,
 *                                              AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
 *
 *                                      LimitEntry = new Entry();
 *                                      LimitEntry.Changed +=
 *                                              new EventHandler(OnLimitChanged);
 *                                      LimitEntry.Activated +=
 *                                              new EventHandler(OnLimitEdited);
 *                                      LimitEntry.FocusOutEvent +=
 *                                              new FocusOutEventHandler(OnLimitFocusLost);
 *                                      LimitEntry.WidthChars = 6;
 *                                      LimitEntry.MaxLength = 10;
 *                                      LimitEntry.Layout.Alignment = Pango.Alignment.Left;
 *                                      diskTable.Attach(LimitEntry, 1,2,1,2,
 *                                              AttachOptions.Shrink | AttachOptions.Fill, 0,0,0);
 *                                      LimitCheckButton.ShowAll();
 *                                      LimitEntry.ShowAll();
 *                              }
 *                              else
 *                              {
 *                                      LimitCheckButton.Visible = true;
 *                                      LimitEntry.Visible = true;
 *                              }
 *
 *                              if(LimitLabel != null)
 *                              {
 *                                      LimitLabel.Visible = false;
 *                                      LimitValue.Visible = false;
 *                              }
 *                      }
 *                      else   */
//			{
            //Commenting the code since Owner of an iFolder canot change the quta settings set by the Admin . 261517
            if (LimitLabel == null)
            {
                LimitLabel        = new Label(Util.GS("Quota:"));
                LimitLabel.Xalign = 0;
                diskTable.Attach(LimitLabel, 0, 1, 0, 1,
                                 AttachOptions.Expand | AttachOptions.Fill, 0, 0, 0);

                LimitValue        = new Label(Util.GS("0"));
                LimitValue.Xalign = 1;
                diskTable.Attach(LimitValue, 1, 2, 0, 1,
                                 AttachOptions.Shrink | AttachOptions.Fill, 0, 0, 0);
                LimitLabel.ShowAll();
                LimitValue.ShowAll();
            }
            else
            {
                LimitLabel.Visible = true;
                LimitValue.Visible = true;
            }

            //LimitCheckButton never assinged, always has value NULL, below code will never get excuted

            /*
             * if(LimitCheckButton != null)
             * {
             *      LimitCheckButton.Visible = false;
             *      LimitEntry.Visible = false;
             * }*/
//			}

            if (ds != null)
            {
                int tmpValue;

                // there is no limit set, disable controls
                if (ds.Limit == -1)
                {
                    LimitUnit.Sensitive           = false;
                    AvailLabel.Sensitive          = false;
                    AvailValue.Sensitive          = false;
                    AvailUnit.Sensitive           = false;
                    DiskUsageBar.Sensitive        = false;
                    DiskUsageFrame.Sensitive      = false;
                    DiskUsageFullLabel.Sensitive  = false;
                    DiskUsageEmptyLabel.Sensitive = false;
                    AvailUnit.Text = "";
                    LimitUnit.Text = "";
                    //LimitCheckButton never assinged, always has value NULL, below code will never get excuted

                    /*	if(LimitCheckButton != null)
                     *      {
                     *              LimitCheckButton.Active = false;
                     *              LimitEntry.Sensitive = false;
                     *              LimitEntry.Text = Util.GS("0");
                     *      }*/
                    if (LimitLabel != null)
                    {
                        LimitLabel.Sensitive = false;
                        LimitValue.Sensitive = false;
                        LimitValue.Text      = Util.GS("N/A");
                    }
                    AvailValue.Text = Util.GS("N/A");
                }
                else
                {
                    LimitUnit.Sensitive           = true;
                    AvailLabel.Sensitive          = true;
                    AvailValue.Sensitive          = true;
                    AvailUnit.Sensitive           = true;
                    DiskUsageBar.Sensitive        = true;
                    DiskUsageFrame.Sensitive      = true;
                    DiskUsageFullLabel.Sensitive  = true;
                    DiskUsageEmptyLabel.Sensitive = true;
                    AvailUnit.Text = Util.GS("MB");
                    LimitUnit.Text = Util.GS("MB");

                    //LimitCheckButton never assinged, always has value NULL, below code will never get excuted

                    /*
                     * if(LimitCheckButton != null)
                     * {
                     *      LimitCheckButton.Active = true;
                     *      LimitEntry.Sensitive = true;
                     *      tmpValue = (int)(ds.Limit / (1024 * 1024));
                     *      LimitEntry.Text = string.Format("{0}", tmpValue);
                     * }*/
                    if (LimitLabel != null)
                    {
                        LimitLabel.Sensitive = true;
                        LimitValue.Sensitive = true;
                        tmpValue             = (int)(ds.Limit / (1024 * 1024));
                        LimitValue.Text      = string.Format("{0}", tmpValue);
                    }

                    tmpValue        = (int)(ds.AvailableSpace / (1024 * 1024));
                    AvailValue.Text = string.Format("{0}", tmpValue);
                }

                SetGraph(ds.UsedSpace, ds.Limit);

                // Add one because there is no iFolder that is zero
                if (ds.UsedSpace == 0)
                {
                    UsedValue.Text = Util.GS("0");
                }
                else
                {
                    tmpValue       = (int)(ds.UsedSpace / (1024 * 1024)) + 1;
                    UsedValue.Text = string.Format("{0}", tmpValue);
                }
            }
            SecureSync.Active = ifolder.ssl;
            // allow User to change the secure sync [ ssl ] if user is owner of iFolder
            if (ifolder.CurrentUserID != ifolder.OwnerID)
            {
                SecureSync.Sensitive = false;
            }

            if (domain.HostUrl.StartsWith(System.Uri.UriSchemeHttps))
            {
                SecureSync.Active    = true;
                SecureSync.Sensitive = false;
            }
        }