Capitalization.

feature-npv2
Icedream 2014-05-07 17:33:31 +02:00
parent a0c75f4122
commit 0d0a3b76fe
21 changed files with 73 additions and 72 deletions

View File

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NPID/@EntryIndexedValue">NPID</s:String></wpf:ResourceDictionary> <s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=NPID/@EntryIndexedValue">NPID</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=RPC/@EntryIndexedValue">RPC</s:String></wpf:ResourceDictionary>

View File

@ -4,18 +4,18 @@ using System.IO;
using System.Net; using System.Net;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using NPSharp.Rpc;
using NPSharp.Rpc.Packets;
using log4net; using log4net;
using NPSharp.RPC;
using NPSharp.RPC.Packets;
namespace NPSharp namespace NPSharp
{ {
/// <summary> /// <summary>
/// Represents a high-level network platform client. /// Represents a high-level network platform client.
/// </summary> /// </summary>
public class NpClient public class NPClient
{ {
private readonly RpcClientStream _rpc; private readonly RPCClientStream _rpc;
private CancellationTokenSource _cancellationTokenSource; private CancellationTokenSource _cancellationTokenSource;
private CancellationToken _cancellationToken; private CancellationToken _cancellationToken;
private ILog _log; private ILog _log;
@ -25,9 +25,9 @@ namespace NPSharp
/// </summary> /// </summary>
/// <param name="host">The host to connect to.</param> /// <param name="host">The host to connect to.</param>
/// <param name="port">The port to use. Default: 3025.</param> /// <param name="port">The port to use. Default: 3025.</param>
public NpClient(string host, ushort port = 3025) public NPClient(string host, ushort port = 3025)
{ {
_rpc = new RpcClientStream(host, port); _rpc = new RPCClientStream(host, port);
_log = LogManager.GetLogger ("NPClient"); _log = LogManager.GetLogger ("NPClient");
} }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1006)] [Packet(1006)]
[ProtoContract] [ProtoContract]
class AuthenticateExternalStatusMessage : RpcServerMessage class AuthenticateExternalStatusMessage : RPCServerMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int Status { get; set; } public int Status { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1010)] [Packet(1010)]
[ProtoContract] [ProtoContract]
class AuthenticateResultMessage : RpcServerMessage class AuthenticateResultMessage : RPCServerMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int Result { get; set; } public int Result { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1003)] [Packet(1003)]
[ProtoContract] [ProtoContract]
class AuthenticateWithTokenMessage : RpcClientMessage class AuthenticateWithTokenMessage : RPCClientMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public string Token { get; set; } public string Token { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(2001)] [Packet(2001)]
[ProtoContract] [ProtoContract]
class CloseAppMessage : RpcServerMessage class CloseAppMessage : RPCServerMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public string Reason { get; set; } public string Reason { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1000)] [Packet(1000)]
[ProtoContract] [ProtoContract]
class HelloMessage : RpcServerMessage class HelloMessage : RPCServerMessage
{ {
// I seriously have no idea where in the code this is used but whatever // I seriously have no idea where in the code this is used but whatever
[ProtoMember(1)] [ProtoMember(1)]

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(2002)] [Packet(2002)]
[ProtoContract] [ProtoContract]
class MessagingSendDataMessage : RpcClientMessage class MessagingSendDataMessage : RPCClientMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public ulong NPID { get; set; } public ulong NPID { get; set; }

View File

@ -1,6 +1,6 @@
using System; using System;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
class PacketAttribute : Attribute class PacketAttribute : Attribute
{ {

View File

@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net; using System.Net;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
public class RpcClientMessage : RpcMessage public class RPCClientMessage : RPCMessage
{ {
public byte[] Serialize(uint id) public byte[] Serialize(uint id)
{ {

View File

@ -1,8 +1,8 @@
using System.Linq; using System.Linq;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
public class RpcMessage public class RPCMessage
{ {
internal const uint Signature = 0xDEADC0DE; // I wonder if aiw3 changed this since kernal noted it in his source code. internal const uint Signature = 0xDEADC0DE; // I wonder if aiw3 changed this since kernal noted it in his source code.

View File

@ -6,13 +6,13 @@ using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using System.Reflection; using System.Reflection;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
public class RpcServerMessage : RpcMessage public class RPCServerMessage : RPCMessage
{ {
public uint MessageId { get; private set; } public uint MessageId { get; private set; }
public static RpcServerMessage Deserialize(NetworkStream ns) public static RPCServerMessage Deserialize(NetworkStream ns)
{ {
var header = new byte[16]; var header = new byte[16];
var l = ns.Read(header, 0, header.Length); var l = ns.Read(header, 0, header.Length);
@ -30,13 +30,13 @@ namespace NPSharp.Rpc.Packets
if (signature != Signature) if (signature != Signature)
throw new ProtocolViolationException("Received packet with invalid signature"); throw new ProtocolViolationException("Received packet with invalid signature");
RpcServerMessage packet; RPCServerMessage packet;
using (var ms = new MemoryStream(buffer)) using (var ms = new MemoryStream(buffer))
{ {
var types = Assembly.GetExecutingAssembly().GetTypes().Where( var types = Assembly.GetExecutingAssembly().GetTypes().Where(
t => t =>
t.IsSubclassOf(typeof (RpcServerMessage)) t.IsSubclassOf(typeof (RPCServerMessage))
&& &&
((PacketAttribute) t.GetCustomAttributes(typeof (PacketAttribute), false).Single()).Type == type ((PacketAttribute) t.GetCustomAttributes(typeof (PacketAttribute), false).Single()).Type == type
).ToArray(); ).ToArray();
@ -53,7 +53,7 @@ namespace NPSharp.Rpc.Packets
return null; return null;
#endif #endif
} }
packet = (RpcServerMessage)ProtoBuf.Serializer.NonGeneric.Deserialize( packet = (RPCServerMessage)ProtoBuf.Serializer.NonGeneric.Deserialize(
types.Single(), types.Single(),
ms ms
); );

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[ProtoContract] [ProtoContract]
[Packet(1101)] [Packet(1101)]
class StorageGetPublisherFileMessage : RpcClientMessage class StorageGetPublisherFileMessage : RPCClientMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public string FileName { get; set; } public string FileName { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1102)] [Packet(1102)]
[ProtoContract] [ProtoContract]
class StorageGetUserFileMessage : RpcClientMessage class StorageGetUserFileMessage : RPCClientMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public string FileName { get; set; } public string FileName { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1111)] [Packet(1111)]
[ProtoContract] [ProtoContract]
class StoragePublisherFileMessage : RpcServerMessage class StoragePublisherFileMessage : RPCServerMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int Result { get; set; } public int Result { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1104)] [Packet(1104)]
[ProtoContract] [ProtoContract]
class StorageSendRandomStringMessage : RpcClientMessage class StorageSendRandomStringMessage : RPCClientMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public string RandomString { get; set; } public string RandomString { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1112)] [Packet(1112)]
[ProtoContract] [ProtoContract]
class StorageUserFileMessage : RpcServerMessage class StorageUserFileMessage : RPCServerMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int Result { get; set; } public int Result { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1103)] [Packet(1103)]
[ProtoContract] [ProtoContract]
class StorageWriteUserFileMessage : RpcClientMessage class StorageWriteUserFileMessage : RPCClientMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public string FileName { get; set; } public string FileName { get; set; }

View File

@ -1,10 +1,10 @@
using ProtoBuf; using ProtoBuf;
namespace NPSharp.Rpc.Packets namespace NPSharp.RPC.Packets
{ {
[Packet(1113)] [Packet(1113)]
[ProtoContract] [ProtoContract]
class StorageWriteUserFileResultMessage : RpcServerMessage class StorageWriteUserFileResultMessage : RPCServerMessage
{ {
[ProtoMember(1)] [ProtoMember(1)]
public int Result { get; set; } public int Result { get; set; }

View File

@ -1,14 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net.Sockets; using System.Net.Sockets;
using NPSharp.Rpc.Packets; using NPSharp.RPC.Packets;
namespace NPSharp.Rpc namespace NPSharp.RPC
{ {
/// <summary> /// <summary>
/// Represents a low-level client stream which can communicate with an NP server using RPC packets. /// Represents a low-level client stream which can communicate with an NP server using RPC packets.
/// </summary> /// </summary>
public class RpcClientStream public class RPCClientStream
{ {
private NetworkStream _ns; private NetworkStream _ns;
private uint _id; private uint _id;
@ -16,14 +16,14 @@ namespace NPSharp.Rpc
private readonly string _host; private readonly string _host;
private readonly ushort _port; private readonly ushort _port;
private readonly Dictionary<uint, Action<RpcServerMessage>> _callbacks = new Dictionary<uint, Action<RpcServerMessage>>(); private readonly Dictionary<uint, Action<RPCServerMessage>> _callbacks = new Dictionary<uint, Action<RPCServerMessage>>();
/// <summary> /// <summary>
/// Initializes an RPC connection stream with a specified host and port. /// Initializes an RPC connection stream with a specified host and port.
/// </summary> /// </summary>
/// <param name="host">The host to connect to.</param> /// <param name="host">The host to connect to.</param>
/// <param name="port">The port to use. Default: 3025.</param> /// <param name="port">The port to use. Default: 3025.</param>
public RpcClientStream(string host, ushort port = 3025) public RPCClientStream(string host, ushort port = 3025)
{ {
_host = host; _host = host;
_port = port; _port = port;
@ -77,7 +77,7 @@ namespace NPSharp.Rpc
/// Attaches a callback to the next message being sent out. This allows handling response packets. /// Attaches a callback to the next message being sent out. This allows handling response packets.
/// </summary> /// </summary>
/// <param name="callback">The method to call when we receive a response to the next message</param> /// <param name="callback">The method to call when we receive a response to the next message</param>
public void AttachCallback(Action<RpcServerMessage> callback) public void AttachCallback(Action<RPCServerMessage> callback)
{ {
if (_callbacks.ContainsKey(_id)) if (_callbacks.ContainsKey(_id))
throw new Exception("There is already a callback for the current message. You can only add max. one callback."); throw new Exception("There is already a callback for the current message. You can only add max. one callback.");
@ -90,7 +90,7 @@ namespace NPSharp.Rpc
/// </summary> /// </summary>
/// <param name="message">The RPC message to send out.</param> /// <param name="message">The RPC message to send out.</param>
/// <returns>The new ID of the message.</returns> /// <returns>The new ID of the message.</returns>
public uint Send(RpcClientMessage message) public uint Send(RPCClientMessage message)
{ {
if (_ns == null) if (_ns == null)
throw new InvalidOperationException("You need to open the stream first."); throw new InvalidOperationException("You need to open the stream first.");
@ -106,12 +106,12 @@ namespace NPSharp.Rpc
/// Waits for the next RPC message from the server and reads it. /// Waits for the next RPC message from the server and reads it.
/// </summary> /// </summary>
/// <returns>The received server message.</returns> /// <returns>The received server message.</returns>
public RpcServerMessage Read() public RPCServerMessage Read()
{ {
if (_ns == null) if (_ns == null)
throw new InvalidOperationException("You need to open the stream first."); throw new InvalidOperationException("You need to open the stream first.");
var message = RpcServerMessage.Deserialize(_ns); var message = RPCServerMessage.Deserialize(_ns);
if (message == null) if (message == null)
return null; return null;

View File

@ -52,26 +52,26 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="NpClient.cs" /> <Compile Include="NPClient.cs" />
<Compile Include="NPFileException.cs" /> <Compile Include="NPFileException.cs" />
<Compile Include="Rpc\RpcClientStream.cs" /> <Compile Include="RPC\RPCClientStream.cs" />
<Compile Include="Rpc\Packets\AuthenticateExternalStatusMessage.cs" /> <Compile Include="RPC\Packets\AuthenticateExternalStatusMessage.cs" />
<Compile Include="Rpc\Packets\AuthenticateResultMessage.cs" /> <Compile Include="RPC\Packets\AuthenticateResultMessage.cs" />
<Compile Include="Rpc\Packets\AuthenticateWithTokenMessage.cs" /> <Compile Include="RPC\Packets\AuthenticateWithTokenMessage.cs" />
<Compile Include="Rpc\Packets\CloseAppMessage.cs" /> <Compile Include="RPC\Packets\CloseAppMessage.cs" />
<Compile Include="Rpc\Packets\HelloMessage.cs" /> <Compile Include="RPC\Packets\HelloMessage.cs" />
<Compile Include="Rpc\Packets\MessagingSendDataMessage.cs" /> <Compile Include="RPC\Packets\MessagingSendDataMessage.cs" />
<Compile Include="Rpc\Packets\RpcMessage.cs" /> <Compile Include="RPC\Packets\RPCMessage.cs" />
<Compile Include="Rpc\Packets\PacketAttribute.cs" /> <Compile Include="RPC\Packets\PacketAttribute.cs" />
<Compile Include="Rpc\Packets\RpcClientMessage.cs" /> <Compile Include="RPC\Packets\RPCClientMessage.cs" />
<Compile Include="Rpc\Packets\RpcServerMessage.cs" /> <Compile Include="RPC\Packets\RPCServerMessage.cs" />
<Compile Include="Rpc\Packets\StorageGetUserFileMessage.cs" /> <Compile Include="RPC\Packets\StorageGetUserFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageGetPublisherFileMessage.cs" /> <Compile Include="RPC\Packets\StorageGetPublisherFileMessage.cs" />
<Compile Include="Rpc\Packets\StoragePublisherFileMessage.cs" /> <Compile Include="RPC\Packets\StoragePublisherFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageSendRandomStringMessage.cs" /> <Compile Include="RPC\Packets\StorageSendRandomStringMessage.cs" />
<Compile Include="Rpc\Packets\StorageUserFileMessage.cs" /> <Compile Include="RPC\Packets\StorageUserFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageWriteUserFileMessage.cs" /> <Compile Include="RPC\Packets\StorageWriteUserFileMessage.cs" />
<Compile Include="Rpc\Packets\StorageWriteUserFileResultMessage.cs" /> <Compile Include="RPC\Packets\StorageWriteUserFileResultMessage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Authentication\AuthenticationHelper.cs" /> <Compile Include="Authentication\AuthenticationHelper.cs" />
</ItemGroup> </ItemGroup>