Commits

Ryan Stecker committed 55ead11

Initial commit.

Comments (0)

Files changed (16)

+syntax: glob
+
+# user files
+*.suo
+
+# temp/binaries
+bin/
+obj/

SkypeKit.NET/Account.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using com.skype.api;
+
+namespace SkypeKit
+{
+    public enum LoginStatus
+    {
+        LoggedOut = 1,
+        LoggedOutAndPasswordSaved = 2,
+        ConnectingToP2P = 3,
+        ConnectingToServer = 4,
+        LoggingIn = 5,
+        Initializing = 6,
+        LoggedIn = 7,
+        LoggingOut = 8,
+    }
+
+    public class SkypeAccount : IDisposable
+    {
+        class Listener : AccountListener
+        {
+            SkypeAccount account;
+
+
+            internal Listener( SkypeAccount account )
+            {
+                this.account = account;
+            }
+
+
+            public void onPropertyChange( Account acc, Account.Property accProp, int intValue, string strValue )
+            {
+                DebugLog.Write( "SkypeAccount", "OnPropertyChange( {0}, {1}, {2}, {3} )", acc, accProp, intValue, strValue );
+            }
+        }
+
+
+        Skype skype;
+        Account account;
+
+        Listener listener;
+
+
+        internal SkypeAccount( Skype skype, Account account )
+        {
+            this.skype = skype;
+            this.account = account;
+
+            listener = new Listener( this );
+            skype.registerAccountListener( listener );
+        }
+
+
+        public void Login( string password, bool savePassword = false )
+        {
+            account.loginWithPassword( password, savePassword, true );
+        }
+
+        public void Logout( bool clearSavedPassword = true )
+        {
+            account.logout( clearSavedPassword );
+        }
+
+        public void Dispose()
+        {
+            skype.unRegisterAccountListener( listener );
+        }
+
+    }
+}

SkypeKit.NET/Client.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using com.skype.api;
+using com.skype.ipc;
+
+namespace SkypeKit
+{
+    public class SkypeClient
+    {
+        class Listener : ConnectionListener
+        {
+            SkypeClient client;
+
+
+            internal Listener( SkypeClient client )
+            {
+                this.client = client;
+            }
+
+
+            public void sidOnConnected()
+            {
+                DebugLog.Write( "SkypeClient", "OnConnected()" );
+            }
+
+            public void sidOnConnecting()
+            {
+                DebugLog.Write( "SkypeClient", "OnConnecting()" );
+            }
+
+            public void sidOnDisconnected( string reason )
+            {
+                DebugLog.Write( "SkypeClient", "OnDisconnected( {0} )", reason );
+            }
+        }
+
+        public class InitSettings
+        {
+            public string KeyPairFile;
+
+            public string RuntimePath;
+            public bool LaunchRuntime = true;
+
+            public string RuntimeLocalAddress = "127.0.0.1";
+            public int RuntimeLocalPort = 8963;
+        }
+
+
+        Skype skype;
+
+        Listener listener;
+
+
+        public SkypeClient()
+        {
+            skype = new Skype();
+
+            listener = new Listener( this );
+        }
+
+
+        public void Initialize( InitSettings settings )
+        {
+            if ( settings == null )
+            {
+                throw new ArgumentNullException( "settings" );
+            }
+
+            if ( string.IsNullOrWhiteSpace( settings.KeyPairFile ) )
+            {
+                throw new ArgumentException( "KeyPairFile is not specified in the initialization settings" );
+            }
+
+            if ( settings.LaunchRuntime )
+            {
+                RuntimeSupport.Start( settings.RuntimePath );
+            }
+
+            var clientConfig = new ClientConfiguration();
+
+            clientConfig.setCertificate( settings.KeyPairFile );
+            clientConfig.setTcpTransport( settings.RuntimeLocalAddress, settings.RuntimeLocalPort );
+
+            if ( !skype.init( clientConfig, listener ) )
+            {
+                throw new SkypeException( "Unable to initialize skypekit" );
+            }
+
+            if ( !skype.start() )
+            {
+                throw new SkypeException( "Unable to start skypekit" );
+            }
+        }
+
+        public SkypeAccount GetAccount( string identity )
+        {
+            var account = skype.getAccount( identity );
+
+            if ( account == null )
+            {
+                throw new SkypeException( string.Format( "Unable to get skype account '{0}'", identity ) );
+            }
+
+            return new SkypeAccount( skype, account );
+        }
+
+        public void Shutdown()
+        {
+            skype.stop();
+        }
+    }
+}

SkypeKit.NET/DebugLog.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SkypeKit
+{
+    public static class DebugLog
+    {
+        public static bool Enabled { get; set; }
+
+
+        static List<Action<string, string>> listeners = new List<Action<string, string>>();
+
+
+        static DebugLog()
+        {
+#if DEBUG
+            Enabled = true;
+#else
+            Enabled = false;
+#endif
+        }
+
+
+        public static void AddListener( Action<string, string> listener )
+        {
+            listeners.Add( listener );
+        }
+
+        public static void Write( string category, string message, params object[] args )
+        {
+            listeners.ForEach( l => l( category, string.Format( message, args ) ) );
+        }
+    }
+}

SkypeKit.NET/Properties/AssemblyInfo.cs

+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle( "SkypeKit.NET" )]
+[assembly: AssemblyDescription( "SkypeKit .NET Bindings" )]
+[assembly: AssemblyConfiguration( "" )]
+[assembly: AssemblyCompany( "Ryan Stecker" )]
+[assembly: AssemblyProduct( "SkypeKit.NET" )]
+[assembly: AssemblyCopyright( "Copyright © Ryan Stecker 2012" )]
+[assembly: AssemblyTrademark( "" )]
+[assembly: AssemblyCulture( "" )]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible( false )]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid( "2b585999-5123-4788-b7a7-ffbf0e736dbb" )]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion( "0.1.*" )]

SkypeKit.NET/RuntimeSupport.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Diagnostics;
+using System.ComponentModel;
+using System.IO;
+
+namespace SkypeKit
+{
+    static class RuntimeSupport
+    {
+        public static void Start( string runtimePath )
+        {
+            var psi = new ProcessStartInfo
+            {
+                FileName = runtimePath,
+                UseShellExecute = false,
+            };
+
+            try
+            {
+                var proc = Process.Start( psi );
+            }
+            catch ( Win32Exception ex )
+            {
+                DebugLog.Write( "RuntimeSupport", "Unable to launch skypekit runtime: {0}", ex.Message );
+                throw;
+            }
+        }
+    }
+}

SkypeKit.NET/SkypeException.cs

+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace SkypeKit
+{
+    public class SkypeException : Exception
+    {
+        public SkypeException()
+        {
+        }
+
+        public SkypeException( string message )
+            : base( message )
+        {
+        }
+
+        public SkypeException( string message, Exception innerException )
+            : base( message, innerException )
+        {
+        }
+    }
+}

SkypeKit.NET/SkypeKit.NET.csproj

+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.30703</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1EEA1CDB-CFBF-44A5-A8AD-01607BD019AE}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>SkypeKit</RootNamespace>
+    <AssemblyName>SkypeKitNET</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <TargetFrameworkProfile />
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <PlatformTarget>AnyCPU</PlatformTarget>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="IKVM.OpenJDK.Core, Version=7.0.4335.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\ThirdParty\IKVM.OpenJDK.Core.dll</HintPath>
+    </Reference>
+    <Reference Include="IKVM.OpenJDK.Security, Version=7.0.4335.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\ThirdParty\IKVM.OpenJDK.Security.dll</HintPath>
+    </Reference>
+    <Reference Include="IKVM.OpenJDK.Text, Version=7.0.4335.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\ThirdParty\IKVM.OpenJDK.Text.dll</HintPath>
+    </Reference>
+    <Reference Include="IKVM.OpenJDK.Util, Version=7.0.4335.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\ThirdParty\IKVM.OpenJDK.Util.dll</HintPath>
+    </Reference>
+    <Reference Include="IKVM.Runtime, Version=7.0.4335.0, Culture=neutral, PublicKeyToken=13235d27fcbfff58, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\ThirdParty\IKVM.Runtime.dll</HintPath>
+    </Reference>
+    <Reference Include="skypekit, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\ThirdParty\skypekit.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="DebugLog.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RuntimeSupport.cs" />
+    <Compile Include="Client.cs" />
+    <Compile Include="Account.cs" />
+    <Compile Include="SkypeException.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkypeKit.NET", "SkypeKit.NET\SkypeKit.NET.csproj", "{1EEA1CDB-CFBF-44A5-A8AD-01607BD019AE}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{1EEA1CDB-CFBF-44A5-A8AD-01607BD019AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{1EEA1CDB-CFBF-44A5-A8AD-01607BD019AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{1EEA1CDB-CFBF-44A5-A8AD-01607BD019AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{1EEA1CDB-CFBF-44A5-A8AD-01607BD019AE}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

ThirdParty/IKVM.OpenJDK.Core.dll

Binary file added.

ThirdParty/IKVM.OpenJDK.Security.dll

Binary file added.

ThirdParty/IKVM.OpenJDK.Text.dll

Binary file added.

ThirdParty/IKVM.OpenJDK.Util.dll

Binary file added.

ThirdParty/IKVM.Runtime.dll

Binary file added.

ThirdParty/skypekit.dll

Binary file added.

ThirdParty/skypekit.pdb

Binary file added.