Changeset 1458 for trunk/CrypP2P


Ignore:
Timestamp:
May 21, 2010, 4:00:55 PM (12 years ago)
Author:
Paul Lelgemann
Message:
  • Removed unused references and using statement in CrypP2P, PeerToPeer, PeerToPeerBaseProxy

+ Skeleton for P2PEditor

Location:
trunk/CrypP2P
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypP2P/CrypP2P.csproj

    r1451 r1458  
    8181      <Private>False</Private>
    8282    </Reference>
    83     <Reference Include="CertServices">
    84       <HintPath>..\AppReferences\CertServices.dll</HintPath>
    85       <Private>False</Private>
    86     </Reference>
    87     <Reference Include="DevComponents.WpfDock">
    88       <HintPath>..\AppExternalReferences\DevComponents.WpfDock.dll</HintPath>
    89       <Private>False</Private>
    90     </Reference>
    91     <Reference Include="DevComponents.WpfEditors">
    92       <HintPath>..\AppExternalReferences\DevComponents.WpfEditors.dll</HintPath>
    93       <Private>False</Private>
    94     </Reference>
    9583    <Reference Include="DevComponents.WpfRibbon">
    9684      <HintPath>..\AppExternalReferences\DevComponents.WpfRibbon.dll</HintPath>
     
    113101      <Private>False</Private>
    114102    </Reference>
    115     <Reference Include="log4net">
    116       <HintPath>..\AppReferences\log4net.dll</HintPath>
    117       <Private>False</Private>
    118     </Reference>
    119     <Reference Include="NetGearsTCP">
    120       <HintPath>..\AppReferences\NetGearsTCP.dll</HintPath>
    121       <Private>False</Private>
    122     </Reference>
    123103    <Reference Include="PeersAtPlayBase">
    124104      <HintPath>..\AppReferences\PeersAtPlayBase.dll</HintPath>
     
    131111      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    132112    </Reference>
    133     <Reference Include="Stun">
    134       <HintPath>..\AppReferences\Stun.dll</HintPath>
    135       <Private>False</Private>
    136     </Reference>
    137113    <Reference Include="System" />
    138     <Reference Include="System.Core">
    139       <RequiredTargetFramework>3.5</RequiredTargetFramework>
    140     </Reference>
    141114    <Reference Include="System.Security" />
    142115    <Reference Include="System.Windows.Forms" />
    143116    <Reference Include="System.Xaml" />
    144     <Reference Include="System.Xml.Linq">
    145       <RequiredTargetFramework>3.5</RequiredTargetFramework>
    146     </Reference>
    147     <Reference Include="System.Data.DataSetExtensions">
    148       <RequiredTargetFramework>3.5</RequiredTargetFramework>
    149     </Reference>
    150     <Reference Include="System.Data" />
    151     <Reference Include="System.Xml" />
    152117    <Reference Include="Util">
    153118      <HintPath>..\AppReferences\Util.dll</HintPath>
  • trunk/CrypP2P/Helper/PAPCertificate.cs

    r1374 r1458  
    11using System;
    22using System.Collections.Generic;
    3 using System.Linq;
    43using System.Text;
    54using System.Security.Cryptography.X509Certificates;
  • trunk/CrypP2P/Internal/P2PBase.cs

    r1436 r1458  
    1616using System;
    1717using System.Collections.Generic;
    18 using System.Linq;
    1918using System.Text;
    2019using PeersAtPlay.P2PStorage.DHT;
     
    2726using PeersAtPlay.P2POverlay.Bootstrapper.IrcBootstrapper;
    2827using System.Threading;
    29 using Cryptool.PluginBase.Control;
    30 using System.ComponentModel;
    3128using PeersAtPlay;
    3229using PeersAtPlay.Util.Logging;
     
    151148        #region Basic P2P Methods (Init, Start, Stop) - synch and asynch
    152149
    153         public void Initialize(P2PSettings p2pSettings)
    154         {
    155             Initialize(p2pSettings.PeerName, p2pSettings.WorldName,
    156                 (P2PLinkManagerType)p2pSettings.LinkManagerType, (P2PBootstrapperType)p2pSettings.BSType,
    157                 (P2POverlayType)p2pSettings.OverlayType, (P2PDHTType)p2pSettings.DhtType);
     150        public void Initialize(P2PSettings p2PSettings)
     151        {
     152            Initialize(p2PSettings.PeerName, p2PSettings.WorldName,
     153                (P2PLinkManagerType)p2PSettings.LinkManagerType, (P2PBootstrapperType)p2PSettings.BsType,
     154                (P2POverlayType)p2PSettings.OverlayType, (P2PDHTType)p2PSettings.DhtType);
    158155        }
    159156
  • trunk/CrypP2P/P2PManager.cs

    r1438 r1458  
    1616
    1717using System;
    18 using System.Collections.Generic;
    19 using System.Text;
    20 using System.ComponentModel;
    21 
     18using System.Windows.Forms;
     19using Cryptool.P2P.Internal;
     20using Cryptool.P2P.Worker;
    2221using Cryptool.PluginBase;
    2322using Cryptool.PluginBase.Miscellaneous;
    24 using System.Windows.Forms;
    25 using Cryptool.P2P.Worker;
     23using Cryptool.Plugins.PeerToPeer.Internal;
    2624using DevComponents.WpfRibbon;
    27 using Cryptool.Plugins.PeerToPeer;
    28 using Cryptool.Plugins.PeerToPeer.Internal;
    29 using Cryptool.P2P.Internal;
    3025
    3126namespace Cryptool.P2P
     
    3429    {
    3530        #region Singleton
    36         static readonly P2PManager INSTANCE = new P2PManager();
    37         private P2PManager() { }
    3831
    39         public static P2PManager Instance
     32        public static readonly P2PManager Instance = new P2PManager();
     33
     34        private P2PManager()
    4035        {
    41             get
    42             {
    43                 return INSTANCE;
    44             }
    4536        }
     37
    4638        #endregion
    4739
    4840        # region Constants
    49         public const string P2PDisconnectImageURI = "images/peer2peer-disconnect.png";
    50         public const string P2PConnectImageURI = "images/peer2peer-connect.png";
     41
     42        public const string P2PDisconnectImageUri = "images/peer2peer-disconnect.png";
     43        public const string P2PConnectImageUri = "images/peer2peer-connect.png";
     44
    5145        # endregion
    5246
    5347        #region Private variables
     48
    5449        public P2PBase P2PBase { get; set; }
    5550        private P2PSettings P2PSettings { get; set; }
    5651        private ButtonDropDown P2PButton { get; set; }
     52
    5753        #endregion
    5854
    5955        #region Events
    60         public static event Cryptool.PluginBase.GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
     56
     57        public static event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
    6158
    6259        // to forward event from overlay/dht MessageReceived-Event from P2PBase
    6360        public event P2PBase.P2PMessageReceived OnPeerMessageReceived;
     61
    6462        #endregion Events
    6563
     
    6866        /// regarding certificates.
    6967        /// </summary>
    70         /// <param name="p2pButton">Button that can change the connection state
     68        /// <param name="p2PButton">Button that can change the connection state
    7169        /// and displays it by showing different images.</param>
    72         public void Initialize(ButtonDropDown p2pButton)
     70        public void Initialize(ButtonDropDown p2PButton)
    7371        {
    74             this.P2PButton = p2pButton;
    75             this.P2PBase = new P2PBase();
    76             this.P2PSettings = new P2PSettings();
    77             this.P2PBase.AllowLoggingToMonitor = this.P2PSettings.Log2Monitor;
     72            P2PButton = p2PButton;
     73            P2PBase = new P2PBase();
     74            P2PSettings = new P2PSettings();
     75            P2PBase.AllowLoggingToMonitor = P2PSettings.Log2Monitor;
    7876
    7977            // Register events
    8078
    8179            // to forward event from overlay/dht MessageReceived-Event from P2PBase
    82             this.P2PBase.OnP2PMessageReceived += new P2PBase.P2PMessageReceived(p2pBase_OnP2PMessageReceived);
     80            P2PBase.OnP2PMessageReceived += p2pBase_OnP2PMessageReceived;
    8381
    8482            // Register exit event to terminate P2P connection without loosing data
    8583            // TODO check if this is correct, should be - but handler is not called (and application does not shut down), probably unrelated to this problem
    86             Application.ApplicationExit += new EventHandler(HandleDisconnectByApplicationShutdown);
     84            Application.ApplicationExit += HandleDisconnectByApplicationShutdown;
    8785        }
    8886
     
    115113        }
    116114
    117         #region DHT operations
    118         // TODO add error handling, if P2P if not connected
    119         public static bool Store(string key, byte[] data)
    120         {
    121             return INSTANCE.P2PBase.SynchStore(key, data);
    122         }
    123 
    124          public static bool Store(string key, string data)
    125         {
    126             return INSTANCE.P2PBase.SynchStore(key, data);
    127         }
    128 
    129         public static byte[] Retrieve(string key)
    130         {
    131             return INSTANCE.P2PBase.SynchRetrieve(key);
    132         }
    133 
    134         public static bool Remove(string key)
    135         {
    136             return INSTANCE.P2PBase.SynchRemove(key);
    137         }
    138         #endregion DHT operations
    139 
    140115        // to forward event from overlay/dht MessageReceived-Event from P2PBase
    141116        private void p2pBase_OnP2PMessageReceived(PeerId sourceAddr, byte[] data)
     
    146121
    147122        #region Framework methods
    148         void HandleDisconnectByApplicationShutdown(object sender, EventArgs e)
     123
     124        private void HandleDisconnectByApplicationShutdown(object sender, EventArgs e)
    149125        {
    150126            if (P2PConnected())
     
    158134            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, null, new GuiLogEventArgs(message, null, logLevel));
    159135        }
     136
    160137        #endregion Framework methods
     138
     139        #region DHT operations
     140
     141        // TODO add error handling, if P2P is not connected
     142        public static bool Store(string key, byte[] data)
     143        {
     144            return Instance.P2PBase.SynchStore(key, data);
     145        }
     146
     147        public static bool Store(string key, string data)
     148        {
     149            return Instance.P2PBase.SynchStore(key, data);
     150        }
     151
     152        public static byte[] Retrieve(string key)
     153        {
     154            return Instance.P2PBase.SynchRetrieve(key);
     155        }
     156
     157        public static bool Remove(string key)
     158        {
     159            return Instance.P2PBase.SynchRemove(key);
     160        }
     161
     162        #endregion DHT operations
    161163    }
    162164}
  • trunk/CrypP2P/P2PSettings.cs

    r1433 r1458  
    1515*/
    1616
    17 using System;
    18 using System.Collections.Generic;
    19 using System.Linq;
    20 using System.Text;
    2117using Cryptool.P2P.Helper;
    2218using Cryptool.P2P.Internal;
     
    2723    public class P2PSettings
    2824    {
    29         public P2PBase Base { get; set; }
    30         public string PeerName { get; set; }
    31         public string WorldName { get; set; }
    32         public bool Log2Monitor { get; set; }
    33         public P2PLinkManagerType LinkManagerType { get; set; }
    34         public P2PBootstrapperType BSType { get; set; }
    35         public P2POverlayType OverlayType { get; set; }
    36         public P2PDHTType DhtType { get; set; }
    37 
    3825        public P2PSettings()
    3926        {
     
    4229            Log2Monitor = true;
    4330            LinkManagerType = P2PLinkManagerType.Snal;
    44             BSType = P2PBootstrapperType.IrcBootstrapper;
     31            BsType = P2PBootstrapperType.IrcBootstrapper;
    4532            OverlayType = P2POverlayType.FullMeshOverlay;
    4633            DhtType = P2PDHTType.FullMeshDHT;
    4734        }
     35
     36        public P2PBase Base { get; set; }
     37        public string PeerName { get; set; }
     38        public string WorldName { get; set; }
     39        public bool Log2Monitor { get; set; }
     40        public P2PLinkManagerType LinkManagerType { get; set; }
     41        public P2PBootstrapperType BsType { get; set; }
     42        public P2POverlayType OverlayType { get; set; }
     43        public P2PDHTType DhtType { get; set; }
    4844    }
    4945}
  • trunk/CrypP2P/Properties/AssemblyInfo.cs

    r1366 r1458  
    1616
    1717using System.Reflection;
    18 using System.Runtime.CompilerServices;
    1918using System.Runtime.InteropServices;
    2019
  • trunk/CrypP2P/Worker/ConnectionWorker.cs

    r1438 r1458  
    1616
    1717using System;
    18 using System.Collections.Generic;
    19 using System.Linq;
    20 using System.Text;
     18using System.ComponentModel;
     19using System.Windows.Controls;
     20using System.Windows.Media;
     21using System.Windows.Media.Imaging;
     22using Cryptool.P2P.Helper;
     23using Cryptool.P2P.Internal;
     24using Cryptool.PluginBase;
    2125using DevComponents.WpfRibbon;
    22 using System.Windows.Controls;
    23 using System.Windows.Media.Imaging;
    24 using System.Windows.Media;
    25 using Cryptool.PluginBase;
    26 using Cryptool.P2P.Internal;
    27 using Cryptool.P2P.Helper;
    2826
    2927namespace Cryptool.P2P.Worker
    3028{
    31     class ConnectionWorker : WorkerBase
     29    internal class ConnectionWorker : WorkerBase
    3230    {
    33         P2PBase p2pBase;
    34         P2PSettings p2pSettings;
    35         ButtonDropDown p2pButton;
     31        private readonly P2PBase _p2PBase;
     32        private readonly ButtonDropDown _p2PButton;
     33        private readonly P2PSettings _p2PSettings;
    3634
    37         public ConnectionWorker(P2PBase p2pBase, P2PSettings p2pSettings, ButtonDropDown p2pButton)
     35        public ConnectionWorker(P2PBase p2PBase, P2PSettings p2PSettings, ButtonDropDown p2PButton)
    3836        {
    39             this.p2pBase = p2pBase;
    40             this.p2pSettings = p2pSettings;
    41             this.p2pButton = p2pButton;
     37            _p2PBase = p2PBase;
     38            _p2PSettings = p2PSettings;
     39            _p2PButton = p2PButton;
    4240        }
    4341
    44         protected override void PerformWork(object sender, System.ComponentModel.DoWorkEventArgs e)
     42        protected override void PerformWork(object sender, DoWorkEventArgs e)
    4543        {
    4644            //p2pButton.IsEnabled = false;
    4745
    48             if (!p2pBase.Started)
     46            if (!_p2PBase.Started)
    4947            {
    5048                P2PManager.Instance.GuiLogMessage("Connecting to P2P network...", NotificationLevel.Info);
     
    5351                if (!PAPCertificate.CheckAndInstallPAPCertificates())
    5452                {
    55                     P2PManager.Instance.GuiLogMessage("Certificates not validated, P2P might not be working!", NotificationLevel.Error);
     53                    P2PManager.Instance.GuiLogMessage("Certificates not validated, P2P might not be working!",
     54                                                      NotificationLevel.Error);
    5655                    return;
    5756                }
    5857
    59                 p2pBase.Initialize(p2pSettings);
    60                 p2pBase.SynchStart();
     58                _p2PBase.Initialize(_p2PSettings);
     59                _p2PBase.SynchStart();
    6160            }
    6261            else
    6362            {
    6463                P2PManager.Instance.GuiLogMessage("Disconnecting from P2P network...", NotificationLevel.Info);
    65                 p2pBase.SynchStop();
     64                _p2PBase.SynchStop();
    6665            }
    6766        }
    6867
    69         protected override void WorkComplete(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
     68        protected override void WorkComplete(object sender, RunWorkerCompletedEventArgs e)
    7069        {
    7170            // Update image according to new state
    72             Image newImage = new Image();
     71            var newImage = new Image();
    7372
    7473            if (P2PManager.Instance.P2PConnected())
    7574            {
    7675                P2PManager.Instance.GuiLogMessage("Connection to P2P network established.", NotificationLevel.Info);
    77                 P2PManager.Instance.GuiLogMessage("P2P user info: " + P2PManager.Instance.UserInfo(), NotificationLevel.Debug);
    78                 newImage.Source = new BitmapImage(new Uri(P2PManager.P2PDisconnectImageURI, UriKind.RelativeOrAbsolute));
     76                P2PManager.Instance.GuiLogMessage("P2P user info: " + P2PManager.Instance.UserInfo(),
     77                                                  NotificationLevel.Debug);
     78                newImage.Source = new BitmapImage(new Uri(P2PManager.P2PDisconnectImageUri, UriKind.RelativeOrAbsolute));
    7979            }
    8080            else
    8181            {
    8282                P2PManager.Instance.GuiLogMessage("Connection to P2P network terminated.", NotificationLevel.Info);
    83                 newImage.Source = new BitmapImage(new Uri(P2PManager.P2PConnectImageURI, UriKind.RelativeOrAbsolute));
     83                newImage.Source = new BitmapImage(new Uri(P2PManager.P2PConnectImageUri, UriKind.RelativeOrAbsolute));
    8484            }
    8585
     
    8787            newImage.Width = 40;
    8888            newImage.Height = 40;
    89             p2pButton.Image = newImage;
     89            _p2PButton.Image = newImage;
    9090
    91             p2pButton.IsEnabled = true;
     91            _p2PButton.IsEnabled = true;
    9292        }
    9393
    9494        protected override void PrePerformWork()
    9595        {
    96             p2pButton.IsEnabled = false;
     96            _p2PButton.IsEnabled = false;
    9797        }
    9898    }
  • trunk/CrypP2P/Worker/WorkerBase.cs

    r1374 r1458  
    1515*/
    1616
    17 using System;
    18 using System.Collections.Generic;
    19 using System.Linq;
    20 using System.Text;
    2117using System.ComponentModel;
    2218
    2319namespace Cryptool.P2P.Worker
    2420{
     21    internal abstract class WorkerBase
     22    {
     23        protected BackgroundWorker BackgroundWorker;
    2524
    26     abstract class WorkerBase
    27     {
    28         protected BackgroundWorker backgroundWorker;
    29 
    30         public WorkerBase()
     25        protected WorkerBase()
    3126        {
    32             backgroundWorker = new BackgroundWorker();
    33             backgroundWorker.DoWork += new DoWorkEventHandler(PerformWork);
    34             backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkComplete);
     27            BackgroundWorker = new BackgroundWorker();
     28            BackgroundWorker.DoWork += PerformWork;
     29            BackgroundWorker.RunWorkerCompleted += WorkComplete;
    3530        }
    3631
     
    3833        {
    3934            PrePerformWork();
    40             backgroundWorker.RunWorkerAsync();
     35            BackgroundWorker.RunWorkerAsync();
    4136        }
    4237
Note: See TracChangeset for help on using the changeset viewer.