Ignore:
Timestamp:
Jun 3, 2010, 3:46:05 PM (12 years ago)
Author:
Paul Lelgemann
Message:

+ P2PEditor: Timer-based refresh of the job list (configurable in seconds)
o CrypP2P: Restored bootstrapper to V2
+ P2PManager: Added asynchronous DHT message calls for completeness

Location:
trunk/CrypPlugins/P2PEditor
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/P2PEditor/Distributed/DistributedJob.cs

    r1563 r1579  
    7979                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    8080        }
     81
     82        public override bool Equals(object obj)
     83        {
     84            if (obj == null || GetType() != obj.GetType())
     85            {
     86                return false;
     87            }
     88
     89            return Equals((DistributedJob) obj);
     90        }
     91
     92        public bool Equals(DistributedJob obj)
     93        {
     94            if (obj == null)
     95            {
     96                return false;
     97            }
     98
     99            return obj.JobGuid == JobGuid;
     100        }
     101
     102        public override int GetHashCode()
     103        {
     104            return JobGuid.GetHashCode();
     105        }
    81106    }
    82107}
  • trunk/CrypPlugins/P2PEditor/Distributed/JobListManager.cs

    r1563 r1579  
    8282
    8383            var currentJobList = JobList();
    84             currentJobList.RemoveAll(x => x.JobGuid == distributedJobToDelete.JobGuid);
     84            currentJobList.Remove(distributedJobToDelete);
    8585
    8686            var memoryStream = new MemoryStream();
  • trunk/CrypPlugins/P2PEditor/GUI/Controls/JobDisplay.xaml.cs

    r1563 r1579  
    22using System.Collections.Generic;
    33using System.ComponentModel;
     4using System.Timers;
    45using System.Windows;
    56using System.Windows.Input;
     
    2122                                                                                    typeof (JobDisplay));
    2223
     24        private Timer _refreshListTimer;
     25
    2326        public JobDisplay()
    2427        {
    2528            InitializeComponent();
     29            UpdateRefreshTimerSettings(P2PManager.Instance.IsP2PConnected());
     30
     31            P2PManager.OnP2PConnectionStateChangeOccurred += P2PManager_OnP2PConnectionStateChangeOccurred;
     32        }
     33
     34        void P2PManager_OnP2PConnectionStateChangeOccurred(object sender, bool newState)
     35        {
     36            UpdateRefreshTimerSettings(newState);
     37        }
     38
     39        private void UpdateRefreshTimerSettings(bool isConnected)
     40        {
     41            if (P2PSettings.Default.DistributedJobListRefreshInterval == 0)
     42            {
     43                return;
     44            }
     45
     46            if (_refreshListTimer == null)
     47            {
     48                _refreshListTimer = new Timer(P2PSettings.Default.DistributedJobListRefreshInterval * 1000);
     49                _refreshListTimer.Elapsed += RefreshListTimerElapsed;
     50            }
     51
     52            if (isConnected)
     53            {
     54                _refreshListTimer.Start();
     55            }
     56            else
     57            {
     58                _refreshListTimer.Stop();
     59            }
     60        }
     61
     62        void RefreshListTimerElapsed(object sender, ElapsedEventArgs e)
     63        {
     64            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateJobList));
    2665        }
    2766
     
    4281        {
    4382            Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateJobList));
    44            
    4583        }
    4684
  • trunk/CrypPlugins/P2PEditor/GUI/P2PEditorPresentation.xaml.cs

    r1563 r1579  
    4242                                        typeof (
    4343                                            P2PEditorPresentation), new PropertyMetadata(false));
    44 
    4544
    4645        public P2PEditorPresentation(P2PEditor p2PEditor, JobListManager jobListManager)
  • trunk/CrypPlugins/P2PEditor/P2PEditorSettings.cs

    r1545 r1579  
    9494        }
    9595
    96         [TaskPane("connectOnStartup_caption", "onnectOnStartup_tooltip", null, 3, true, DisplayLevel.Experienced,
     96        [TaskPane("distributedJobListRefreshInterval_caption", "distributedJobListRefreshInterval_tooltip", null, 3, false, DisplayLevel.Experienced,
     97            ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
     98        public int DistributedJobListRefreshInterval
     99        {
     100            get { return _settings.DistributedJobListRefreshInterval; }
     101            set
     102            {
     103                if (value != _settings.DistributedJobListRefreshInterval)
     104                {
     105                    _settings.DistributedJobListRefreshInterval = value;
     106                    OnPropertyChanged("DistributedJobListRefreshInterval");
     107                    HasChanges = true;
     108                }
     109            }
     110        }
     111
     112        [TaskPane("connectOnStartup_caption", "onnectOnStartup_tooltip", null, 4, true, DisplayLevel.Experienced,
    97113            ControlType.CheckBox)]
    98114        public bool ConnectOnStartup
     
    111127
    112128        // TODO make button obsolete - stop button should be fine, but is currently not suited (see todo in P2PEditor:Stop())
    113         [TaskPane("stop_caption", "stop_tooltip", null, 4, true, DisplayLevel.Beginner, ControlType.Button)]
     129        [TaskPane("stop_caption", "stop_tooltip", null, 5, true, DisplayLevel.Beginner, ControlType.Button)]
    114130        public void BtnStop()
    115131        {
     
    122138
    123139        // TODO make button obsolete - find appropriate display method
    124         [TaskPane("log_connection_state_caption", "log_connection_state_tooltip", null, 5, true, DisplayLevel.Beginner,
     140        [TaskPane("log_connection_state_caption", "log_connection_state_tooltip", null, 6, true, DisplayLevel.Beginner,
    125141            ControlType.Button)]
    126142        public void BtnLogConnectionState()
     
    196212        }
    197213
    198         [TaskPane("log2monitor_caption", "log2monitor_tooltip", GroupExpert, 4, false, DisplayLevel.Expert,
     214        [TaskPane("localPort_caption", "localPort_tooltip", GroupExpert, 4, false, DisplayLevel.Expert,
     215            ControlType.NumericUpDown, ValidationType.RangeInteger, 0, 65535)]
     216        public int LocalPort
     217        {
     218            get { return _settings.LocalPort; }
     219            set
     220            {
     221                if (value != _settings.LocalPort)
     222                {
     223                    _settings.LocalPort = value;
     224                    OnPropertyChanged("LocalPort");
     225                    HasChanges = true;
     226                }
     227            }
     228        }
     229
     230        [TaskPane("log2monitor_caption", "log2monitor_tooltip", GroupExpert, 5, false, DisplayLevel.Expert,
    199231            ControlType.CheckBox)]
    200232        public bool Log2Monitor
  • trunk/CrypPlugins/P2PEditor/Resources/Attributes.Designer.cs

    r1527 r1579  
    116116       
    117117        /// <summary>
     118        ///   Looks up a localized string similar to Job list refresh interval (seconds).
     119        /// </summary>
     120        internal static string distributedJobListRefreshInterval_caption {
     121            get {
     122                return ResourceManager.GetString("distributedJobListRefreshInterval_caption", resourceCulture);
     123            }
     124        }
     125       
     126        /// <summary>
     127        ///   Looks up a localized string similar to Refreshes the the distributed job list in the given interval. A value of 0 will disable the automated process..
     128        /// </summary>
     129        internal static string distributedJobListRefreshInterval_tooltip {
     130            get {
     131                return ResourceManager.GetString("distributedJobListRefreshInterval_tooltip", resourceCulture);
     132            }
     133        }
     134       
     135        /// <summary>
    118136        ///   Looks up a localized string similar to LinkManager type.
    119137        /// </summary>
     
    130148            get {
    131149                return ResourceManager.GetString("linkmanager_tooltip", resourceCulture);
     150            }
     151        }
     152       
     153        /// <summary>
     154        ///   Looks up a localized string similar to Local port.
     155        /// </summary>
     156        internal static string localPort_caption {
     157            get {
     158                return ResourceManager.GetString("localPort_caption", resourceCulture);
     159            }
     160        }
     161       
     162        /// <summary>
     163        ///   Looks up a localized string similar to Local port used by the framework. If set to 0, the framework will choose a random port..
     164        /// </summary>
     165        internal static string localPort_tooltip {
     166            get {
     167                return ResourceManager.GetString("localPort_tooltip", resourceCulture);
    132168            }
    133169        }
  • trunk/CrypPlugins/P2PEditor/Resources/Attributes.resx

    r1527 r1579  
    136136    <value>DHT type</value>
    137137  </data>
     138  <data name="distributedJobListRefreshInterval_caption" xml:space="preserve">
     139    <value>Job list refresh interval (seconds)</value>
     140  </data>
     141  <data name="distributedJobListRefreshInterval_tooltip" xml:space="preserve">
     142    <value>Refreshes the the distributed job list in the given interval. A value of 0 will disable the automated process.</value>
     143  </data>
    138144  <data name="linkmanager_caption" xml:space="preserve">
    139145    <value>LinkManager type</value>
     
    142148    <value>LinkManager type</value>
    143149  </data>
     150  <data name="localPort_caption" xml:space="preserve">
     151    <value>Local port</value>
     152  </data>
     153  <data name="localPort_tooltip" xml:space="preserve">
     154    <value>Local port used by the framework. If set to 0, the framework will choose a random port.</value>
     155  </data>
    144156  <data name="log2monitor_caption" xml:space="preserve">
    145157    <value>Syslog</value>
Note: See TracChangeset for help on using the changeset viewer.