├── IronTwit ├── .getignore ├── Mockups │ └── Main UI.png ├── build │ └── Unite.Setup.msi ├── IronTwit │ ├── WPF.Themes.dll │ ├── WPFToolkit.dll │ ├── UI │ │ ├── WPF.Themes.dll │ │ ├── WPFToolkit.dll │ │ ├── Properties │ │ │ ├── Settings.settings │ │ │ ├── Settings.Designer.cs │ │ │ ├── AssemblyInfo.cs │ │ │ ├── Resources.Designer.cs │ │ │ └── Resources.resx │ │ ├── Utilities │ │ │ ├── Extensions.cs │ │ │ ├── UIThreadManager.cs │ │ │ ├── UiMessage.cs │ │ │ ├── ContactProvider.cs │ │ │ ├── InlineUrls.cs │ │ │ └── GuiInteractionContext.cs │ │ ├── Controls │ │ │ ├── MessageView.xaml.cs │ │ │ ├── MessageView.xaml │ │ │ └── MessageTextView.cs │ │ ├── ViewModels │ │ │ ├── SendMessageCommand.cs │ │ │ ├── DelegateCommand.cs │ │ │ ├── UserCredentialsViewModel.cs │ │ │ └── ReceiveMessagesCommand.cs │ │ ├── App.xaml.cs │ │ ├── Themes │ │ │ └── Generic.xaml │ │ ├── IoC_Configuration.cs │ │ ├── Views │ │ │ ├── UserCredentials.xaml.cs │ │ │ ├── UserCredentials.xaml │ │ │ ├── MainView.xaml.cs │ │ │ └── MainView.xaml │ │ └── DraggableWindow.cs │ ├── Messaging │ │ ├── Services │ │ │ ├── IPluginFinder.cs │ │ │ ├── IServiceResolver.cs │ │ │ ├── ISettingsProvider.cs │ │ │ ├── MessageReceivedEventArgs.cs │ │ │ ├── IServiceProvider.cs │ │ │ ├── ServiceResolver.cs │ │ │ ├── PluginFinder.cs │ │ │ ├── ServiceProvider.cs │ │ │ └── ServicesManager.cs │ │ ├── Entities │ │ │ ├── IServiceInformation.cs │ │ │ ├── IMessage.cs │ │ │ ├── Credentials.cs │ │ │ ├── Contact.cs │ │ │ ├── ServiceInformation.cs │ │ │ └── Identity.cs │ │ ├── Prompts │ │ │ └── IInteractionContext.cs │ │ ├── Messages │ │ │ ├── IMessagingServiceManager.cs │ │ │ ├── IMessagingServiceRegistry.cs │ │ │ ├── ICredentialCache.cs │ │ │ ├── MessagingAccount.cs │ │ │ ├── CredentialEventArgs.cs │ │ │ └── IMessagingService.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── Unite.Messaging.csproj │ ├── Specs │ │ ├── New_Starting_Application_Specs │ │ │ ├── Sending_message.cs │ │ │ ├── Starting_app_vanilla_with_messages.cs │ │ │ ├── FakePlugin.cs │ │ │ ├── When_application_starts_receiving_with_no_valid_credentials.cs │ │ │ └── ScenarioRepository.cs │ │ ├── TwitterServicesScope │ │ │ ├── Formatting_messages_for_twitter.cs │ │ │ ├── When_sending_large_messages.cs │ │ │ ├── When_receiving_messages.cs │ │ │ └── When_sending_normal_messages.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Application_running │ │ │ ├── Class1.cs │ │ │ ├── When_replying_to_a_message.cs │ │ │ └── Context.cs │ │ ├── UnitTests │ │ │ ├── ServiceResolverTests.cs │ │ │ └── InlineUrlsTests.cs │ │ ├── Starting_Application │ │ │ ├── Start_application_receive_message_specs.cs │ │ │ ├── User_enters_wrong_password_when_prompted.cs │ │ │ └── Start_application_send_message_spec.cs │ │ ├── Using_Services │ │ │ └── When_getting_messages.cs │ │ ├── Utilities │ │ │ └── SpecUnit.cs │ │ ├── Contacts │ │ │ └── When_receiving_messages_with_known_contacts.cs │ │ └── Unite.Specs.csproj │ ├── Plug Ins │ │ ├── IronTwitterPlugIn │ │ │ ├── ITwitterDataAccess.cs │ │ │ ├── DataObjects │ │ │ │ ├── TwitterUser.cs │ │ │ │ └── Tweet.cs │ │ │ ├── TwitterDataAccess.cs │ │ │ ├── Properties │ │ │ │ └── AssemblyInfo.cs │ │ │ └── IronTwitterPlugIn.csproj │ │ └── GoogleTalkPlugIn │ │ │ ├── GTalkMessage.cs │ │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ │ ├── GoogleTalkDataAccess.cs │ │ │ ├── GoogleTalkPlugIn.csproj │ │ │ └── GoogleTalkMessagingService.cs │ ├── Unite.TestHarness │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── Program.cs │ │ └── Unite.TestHarness.csproj │ └── Unite.Setup │ │ └── Unite.Setup.wixproj ├── ThirdParty │ ├── IoC │ │ ├── StructureMap.chm │ │ ├── StructureMap.dll │ │ └── StructureMap.AutoMocking.dll │ ├── Mocking │ │ └── Rhino.Mocks.dll │ ├── WPFToolKit │ │ ├── WPF.Themes.dll │ │ └── WPFToolkit.dll │ ├── JabberLibrary │ │ ├── jabber-net.dll │ │ ├── netlib.Dns.dll │ │ └── zlib.net.dll │ ├── UnitTesting │ │ ├── nunit.core.dll │ │ ├── nunit.util.dll │ │ ├── nunit-console.exe │ │ ├── nunit.framework.dll │ │ ├── nunit-console-runner.dll │ │ ├── nunit.core.interfaces.dll │ │ ├── nunit.framework.extensions.dll │ │ └── nunit-console.exe.config │ ├── TwitterComm │ │ ├── Yedda.Twitter.dll │ │ └── Newtonsoft.Json.dll │ └── WpfBindingHelpers │ │ └── Bound.Net.dll ├── InstallGems.bat ├── RakeFile └── BuildUtils.rb └── .gitignore /IronTwit/.getignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _ReSharper* 2 | *.resharper* 3 | bin 4 | obj 5 | *.suo 6 | *.zip 7 | *.cache -------------------------------------------------------------------------------- /IronTwit/Mockups/Main UI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/Mockups/Main UI.png -------------------------------------------------------------------------------- /IronTwit/build/Unite.Setup.msi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/build/Unite.Setup.msi -------------------------------------------------------------------------------- /IronTwit/IronTwit/WPF.Themes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/WPF.Themes.dll -------------------------------------------------------------------------------- /IronTwit/IronTwit/WPFToolkit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/WPFToolkit.dll -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/WPF.Themes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/UI/WPF.Themes.dll -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/WPFToolkit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/UI/WPFToolkit.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/IoC/StructureMap.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/IoC/StructureMap.chm -------------------------------------------------------------------------------- /IronTwit/ThirdParty/IoC/StructureMap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/IoC/StructureMap.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/Mocking/Rhino.Mocks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/Mocking/Rhino.Mocks.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/WPFToolKit/WPF.Themes.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/WPFToolKit/WPF.Themes.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/WPFToolKit/WPFToolkit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/WPFToolKit/WPFToolkit.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/JabberLibrary/jabber-net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/JabberLibrary/jabber-net.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/JabberLibrary/netlib.Dns.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/JabberLibrary/netlib.Dns.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/JabberLibrary/zlib.net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/JabberLibrary/zlib.net.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit.core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.core.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit.util.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.util.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/TwitterComm/Yedda.Twitter.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/TwitterComm/Yedda.Twitter.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit-console.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit-console.exe -------------------------------------------------------------------------------- /IronTwit/ThirdParty/IoC/StructureMap.AutoMocking.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/IoC/StructureMap.AutoMocking.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/TwitterComm/Newtonsoft.Json.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/TwitterComm/Newtonsoft.Json.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.framework.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/WpfBindingHelpers/Bound.Net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/WpfBindingHelpers/Bound.Net.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit-console-runner.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit-console-runner.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit.core.interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.core.interfaces.dll -------------------------------------------------------------------------------- /IronTwit/ThirdParty/UnitTesting/nunit.framework.extensions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.framework.extensions.dll -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/IPluginFinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Unite.Messaging.Services 5 | { 6 | public interface IPluginFinder 7 | { 8 | IEnumerable GetAllPlugins(); 9 | } 10 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/IServiceResolver.cs: -------------------------------------------------------------------------------- 1 | using Unite.Messaging.Entities; 2 | 3 | namespace Unite.Messaging.Services 4 | { 5 | public interface IServiceResolver 6 | { 7 | ServiceInformation GetService(string address); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/New_Starting_Application_Specs/Sending_message.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | 3 | namespace Unite.Specs.New_Starting_Application_Specs 4 | { 5 | [TestFixture] 6 | public class When_sending_a_message 7 | { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Entities/IServiceInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Unite.Messaging.Entities 4 | { 5 | public interface IServiceInformation 6 | { 7 | string ServiceName { get; } 8 | Guid ServiceID { get; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Entities/IMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Unite.Messaging.Entities 4 | { 5 | public interface IMessage 6 | { 7 | string Text { get; set; } 8 | IIdentity Address { get; set; } 9 | DateTime TimeStamp { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Prompts/IInteractionContext.cs: -------------------------------------------------------------------------------- 1 | using Unite.Messaging.Entities; 2 | 3 | namespace Unite.Messaging 4 | { 5 | public interface IInteractionContext 6 | { 7 | Credentials GetCredentials(IServiceInformation serviceInformation); 8 | bool AuthenticationFailedRetryQuery(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/ISettingsProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Unite.Messaging.Services 7 | { 8 | public interface ISettingsProvider 9 | { 10 | IEnumerable GetStoredCredentials(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Messages/IMessagingServiceManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging.Messages; 6 | 7 | namespace Unite.Messaging 8 | { 9 | public interface IMessagingServiceManager : IMessagingService 10 | { 11 | void SendMessage(string recipient, string message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Messages/IMessagingServiceRegistry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Unite.Messaging.Messages 5 | { 6 | public interface IMessagingServiceRegistry 7 | { 8 | List RegisteredServices { get; } 9 | 10 | void Register(IMessagingService service); 11 | 12 | IMessagingService Get(Guid id); 13 | } 14 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Messages/ICredentialCache.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Unite.Messaging.Messages 4 | { 5 | public interface ICredentialCache 6 | { 7 | void Add(Guid serviceId, Credentials credentials); 8 | void Clear(Guid serviceId, string userName); 9 | bool Contains(Guid serviceId, string userName); 10 | void Clear(Guid serviceId); 11 | void ClearAll(); 12 | } 13 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Messages/MessagingAccount.cs: -------------------------------------------------------------------------------- 1 | namespace Unite.Messaging.Messages 2 | { 3 | public struct MessagingAccount 4 | { 5 | public MessagingAccount(IMessagingService service, Credentials credentials) 6 | { 7 | Service = service; 8 | Credentials = credentials; 9 | } 10 | 11 | public IMessagingService Service; 12 | public Credentials Credentials; 13 | } 14 | } -------------------------------------------------------------------------------- /IronTwit/InstallGems.bat: -------------------------------------------------------------------------------- 1 | @ECHO *** Installing Rake 2 | @call gem install rake --include-dependencies 3 | 4 | @ECHO *** Installing ActiveRecord 5 | @call gem install activerecord --include-dependencies 6 | 7 | @ECHO *** Installing RubyZip 8 | @call gem install rubyzip --include-dependencies 9 | 10 | @ECHO *** Installing Rails 11 | @call gem install rails --include-dependencies 12 | 13 | @ECHO *** Installing Guid 14 | @call gem install guid --include-dependencies -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Entities/Credentials.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging.Entities; 6 | 7 | namespace Unite.Messaging 8 | { 9 | public class Credentials 10 | { 11 | public string UserName { get; set; } 12 | public string Password { get; set; } 13 | public IServiceInformation ServiceInformation { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Entities/Contact.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Unite.Messaging 7 | { 8 | public class Contact 9 | { 10 | public Guid ContactId 11 | { 12 | get; set; 13 | } 14 | 15 | public IEnumerable Identities 16 | { 17 | get; set; 18 | } 19 | 20 | public string Name 21 | { 22 | get; set; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/ITwitterDataAccess.cs: -------------------------------------------------------------------------------- 1 | using Unite.Messaging; 2 | 3 | namespace IronTwitterPlugIn 4 | { 5 | public interface ITwitterDataAccess 6 | { 7 | /// 8 | /// Returns a status in JSON. 9 | /// 10 | /// 11 | /// 12 | /// 13 | string SendMessage(Credentials credentials, string message); 14 | string GetMessages(Credentials credentials); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/MessageReceivedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging.Entities; 6 | 7 | namespace Unite.Messaging.Services 8 | { 9 | public class MessagesReceivedEventArgs : EventArgs 10 | { 11 | public MessagesReceivedEventArgs(IEnumerable messages) 12 | { 13 | Messages = messages; 14 | } 15 | 16 | public IEnumerable Messages 17 | { 18 | get; set; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Utilities/Extensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Unite.UI.Utilities 7 | { 8 | public static class Unit3Extensions 9 | { 10 | public static IEnumerable Convert(this IEnumerable items, Func converter) 11 | { 12 | var result = new List(); 13 | 14 | foreach(var item in items) 15 | { 16 | result.Add(converter(item)); 17 | } 18 | 19 | return result; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/IServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Unite.Messaging.Entities; 4 | using Unite.Messaging.Messages; 5 | 6 | namespace Unite.Messaging.Services 7 | { 8 | public interface IServiceProvider 9 | { 10 | void Add(params IMessagingService[] services); 11 | IEnumerable GetServices(); 12 | event EventHandler CredentialsRequested; 13 | event EventHandler AuthorizationFailed; 14 | IMessagingService GetService(ServiceInformation info); 15 | } 16 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/DataObjects/TwitterUser.cs: -------------------------------------------------------------------------------- 1 | using Unite.Messaging; 2 | using Unite.Messaging.Entities; 3 | 4 | namespace IronTwitterPlugIn.DataObjects 5 | { 6 | public class TwitterUser : IIdentity 7 | { 8 | /// 9 | /// for de/serialization only (alias to UserName) 10 | /// 11 | public string screen_name 12 | { 13 | get { return UserName; } 14 | set { UserName = value; } 15 | } 16 | 17 | public string UserName { get; set; } 18 | public ServiceInformation ServiceInfo 19 | { 20 | get; set; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Controls/MessageView.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Navigation; 13 | using System.Windows.Shapes; 14 | 15 | namespace Unite.UI.Controls 16 | { 17 | public partial class MessageView : UserControl 18 | { 19 | public MessageView() 20 | { 21 | InitializeComponent(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Utilities/UIThreadManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Windows.Threading; 7 | 8 | namespace Unite.UI.Utilities 9 | { 10 | public class UIThreadManager 11 | { 12 | private Thread _Thread; 13 | 14 | public UIThreadManager(Thread thread) 15 | { 16 | _Thread = thread; 17 | } 18 | 19 | public void Execute(Action action) 20 | { 21 | var dispatcher = Dispatcher.FromThread(_Thread); 22 | dispatcher.Invoke(DispatcherPriority.Normal, action); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Messages/CredentialEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unite.Messaging.Entities; 3 | 4 | namespace Unite.Messaging.Messages 5 | { 6 | public class CredentialEventArgs : EventArgs 7 | { 8 | public ServiceInformation ServiceInfo; 9 | 10 | public bool Equals(CredentialEventArgs obj) 11 | { 12 | if (ReferenceEquals(null, obj)) return false; 13 | if (ReferenceEquals(this, obj)) return true; 14 | return Equals(obj.ServiceInfo, ServiceInfo); 15 | } 16 | 17 | public override int GetHashCode() 18 | { 19 | return (ServiceInfo != null ? ServiceInfo.GetHashCode() : 0); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/TwitterServicesScope/Formatting_messages_for_twitter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.UI.Utilities; 6 | using NUnit.Framework; 7 | using SpecUnit; 8 | 9 | namespace Unite.Specs.UnitTests 10 | { 11 | [TestFixture] 12 | public class Formatting_messages_for_twitter 13 | { 14 | [Test] 15 | public void TestOne() 16 | { 17 | var finalMessage = "@darkxanthos This"; 18 | //var result = TwitterUtilities._GetMessageToSend(finalMessage.Length, "This is my message."); 19 | 20 | //result.ShouldEqual(finalMessage); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/ViewModels/SendMessageCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Input; 3 | using Unite.UI.Utilities; 4 | using StructureMap; 5 | 6 | namespace Unite.UI.ViewModels 7 | { 8 | public class SendMessageCommand : ICommand 9 | { 10 | private Action _OnSendMessage; 11 | 12 | public SendMessageCommand(Action onSendMessage) 13 | { 14 | _OnSendMessage = onSendMessage; 15 | } 16 | 17 | public event EventHandler CanExecuteChanged; 18 | public void Execute(object parameter) 19 | { 20 | if (_OnSendMessage != null) 21 | _OnSendMessage(); 22 | } 23 | 24 | public bool CanExecute(object parameter) 25 | { 26 | return true; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/ServiceResolver.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Unite.Messaging.Entities; 3 | using Unite.Messaging.Messages; 4 | 5 | namespace Unite.Messaging.Services 6 | { 7 | public class ServiceResolver : IServiceResolver 8 | { 9 | public ServiceResolver(IServiceProvider provider) 10 | { 11 | _Services = provider.GetServices(); 12 | } 13 | 14 | private readonly IEnumerable _Services; 15 | 16 | public ServiceInformation GetService(string address) 17 | { 18 | foreach(var service in _Services) 19 | { 20 | if (service.CanFind(address)) 21 | return service.GetInformation(); 22 | } 23 | 24 | return null; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Collections.ObjectModel; 4 | using System.Configuration; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Windows; 8 | using Unite.UI.ViewModels; 9 | using StructureMap; 10 | 11 | namespace Unite.UI 12 | { 13 | /// 14 | /// Interaction logic for App.xaml 15 | /// 16 | public partial class App : Application 17 | { 18 | public App() 19 | { 20 | Startup += App_Startup; 21 | } 22 | 23 | void App_Startup(object sender, StartupEventArgs e) 24 | { 25 | ContainerBootstrapper.BootstrapStructureMap(); 26 | 27 | var view = ObjectFactory.GetInstance(); 28 | view.Show(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Messages/IMessagingService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Unite.Messaging.Entities; 4 | using Unite.Messaging.Services; 5 | 6 | namespace Unite.Messaging.Messages 7 | { 8 | public interface IMessagingService 9 | { 10 | bool CanAccept(Credentials credentials); 11 | List GetMessages(); 12 | void SendMessage(IIdentity recipient, string message); 13 | void SetCredentials(Credentials credentials); 14 | event EventHandler CredentialsRequested; 15 | event EventHandler AuthorizationFailed; 16 | bool CanFind(string address); 17 | ServiceInformation GetInformation(); 18 | void StartReceiving(); 19 | void StopReceiving(); 20 | event EventHandler MessagesReceived; 21 | } 22 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/GTalkMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging; 6 | using Unite.Messaging.Entities; 7 | 8 | namespace GoogleTalkPlugIn 9 | { 10 | internal class GTalkMessage : IMessage 11 | { 12 | public string Text 13 | { 14 | get; set; 15 | } 16 | 17 | public IIdentity Address 18 | { 19 | get; set; 20 | } 21 | 22 | public DateTime TimeStamp 23 | { 24 | get; set; 25 | } 26 | } 27 | 28 | internal class GTalkUser : IIdentity 29 | { 30 | public string UserName 31 | { 32 | get; set; 33 | } 34 | 35 | public ServiceInformation ServiceInfo 36 | { 37 | get; set; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Utilities/UiMessage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging; 6 | using Unite.Messaging.Entities; 7 | 8 | namespace Unite.UI.Utilities 9 | { 10 | public class UiMessage : IMessage 11 | { 12 | public UiMessage(IMessage message, Contact contact) 13 | { 14 | Address = message.Address; 15 | Text = message.Text; 16 | TimeStamp = message.TimeStamp; 17 | Contact = contact; 18 | } 19 | 20 | public string Text 21 | { 22 | get; set; 23 | } 24 | 25 | public IIdentity Address 26 | { 27 | get; set; 28 | } 29 | 30 | public DateTime TimeStamp 31 | { 32 | get; set; 33 | } 34 | 35 | public Contact Contact 36 | { 37 | get; set; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 19 | 20 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Controls/MessageView.xaml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/TwitterDataAccess.cs: -------------------------------------------------------------------------------- 1 | using Unite.Messaging; 2 | using Yedda; 3 | 4 | namespace IronTwitterPlugIn 5 | { 6 | public class TwitterDataAccess : ITwitterDataAccess 7 | { 8 | public string SendMessage(Credentials credentials, string message) 9 | { 10 | var twit = new Twitter(); 11 | twit.TwitterClient = "Unite"; 12 | twit.TwitterClientUrl = "http://github.com/jcbozonier/irontwit/tree/master"; 13 | twit.TwitterClientVersion = "0.1"; 14 | 15 | var result = twit.UpdateAsJSON(credentials.UserName, credentials.Password, message); 16 | return result; 17 | } 18 | 19 | public string GetMessages(Credentials credentials) 20 | { 21 | var twit = new Twitter(); 22 | twit.TwitterClient = "Unite"; 23 | twit.TwitterClientUrl = "http://github.com/jcbozonier/irontwit/tree/master"; 24 | twit.TwitterClientVersion = "0.1"; 25 | 26 | var result = twit.GetFriendsTimelineAsJSON(credentials.UserName, credentials.Password); 27 | return result; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/DataObjects/Tweet.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unite.Messaging; 3 | using Unite.Messaging.Entities; 4 | 5 | namespace IronTwitterPlugIn.DataObjects 6 | { 7 | public class Tweet : IMessage 8 | { 9 | /// 10 | /// for de/serialization only (alias to Text) 11 | /// 12 | public string text 13 | { 14 | get { return Text; } 15 | set { Text = value; } 16 | } 17 | 18 | public string Text { get; set; } 19 | 20 | /// 21 | /// for de/serialization only (alias to Sender) 22 | /// 23 | public TwitterUser user 24 | { 25 | get { return (TwitterUser)Address; } 26 | set 27 | { 28 | if (!value.UserName.StartsWith("@")) 29 | value.UserName = "@" + value.UserName; 30 | Address = value; 31 | } 32 | } 33 | public int id { get; set; } 34 | 35 | public IIdentity Address { get; set; } 36 | public DateTime TimeStamp 37 | { 38 | get; set; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/IoC_Configuration.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Unite.Messaging.Services; 3 | using Unite.UI.Utilities; 4 | using StructureMap; 5 | using Unite.Messaging; 6 | 7 | namespace Unite.UI 8 | { 9 | public static class ContainerBootstrapper 10 | { 11 | public static void BootstrapStructureMap() 12 | { 13 | // Initialize the static ObjectFactory container 14 | ObjectFactory.Initialize(x => 15 | { 16 | x.ForRequestedType().TheDefaultIsConcreteType(); 17 | x.ForRequestedType().TheDefault.IsThis( 18 | new GuiInteractionContext(Thread.CurrentThread)); 19 | x.ForRequestedType().TheDefaultIsConcreteType(); 20 | x.ForRequestedType().TheDefaultIsConcreteType(); 21 | x.ForRequestedType().TheDefaultIsConcreteType(); 22 | x.ForRequestedType().TheDefaultIsConcreteType(); 23 | }); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/ViewModels/DelegateCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows.Input; 6 | 7 | namespace Unite.UI.ViewModels 8 | { 9 | public class Do : ICommand 10 | { 11 | private Action _Action; 12 | private Predicate _Pred; 13 | 14 | public Do(Action action) 15 | { 16 | _Action = action; 17 | } 18 | 19 | public void If(Predicate pred) 20 | { 21 | _Pred = pred; 22 | } 23 | 24 | public event EventHandler CanExecuteChanged; 25 | 26 | public void Execute(object parameter) 27 | { 28 | if(!(parameter is T)) 29 | throw new ArgumentException("parameter doesn't match the type."); 30 | _Action((T) parameter); 31 | } 32 | 33 | public bool CanExecute(object parameter) 34 | { 35 | if(_Pred == null) 36 | throw new NullReferenceException("You must provide a predicate to tell when an action can be carried out."); 37 | return _Pred((T) parameter); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:2.0.50727.1434 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace Unite.UI.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Views/UserCredentials.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using System.Windows.Documents; 9 | using System.Windows.Input; 10 | using System.Windows.Media; 11 | using System.Windows.Media.Imaging; 12 | using System.Windows.Shapes; 13 | using Unite.UI.ViewModels; 14 | 15 | namespace Unite.UI.Views 16 | { 17 | /// 18 | /// Interaction logic for UserCredentials.xaml 19 | /// 20 | public partial class UserCredentialsWindow : DraggableWindow 21 | { 22 | public UserCredentialsWindow() 23 | { 24 | InitializeComponent(); 25 | } 26 | 27 | private void Password_PasswordChanged(object sender, RoutedEventArgs e) 28 | { 29 | ((UserCredentialsViewModel) DataContext).Password = Password.Password; 30 | } 31 | 32 | private void Ok_Click(object sender, RoutedEventArgs e) 33 | { 34 | DialogResult = true; 35 | } 36 | 37 | private void Cancel_Click(object sender, RoutedEventArgs e) 38 | { 39 | DialogResult = false; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/ViewModels/UserCredentialsViewModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Windows; 6 | 7 | namespace Unite.UI.ViewModels 8 | { 9 | public class UserCredentialsViewModel : DependencyObject 10 | { 11 | public static DependencyProperty UserNameProperty = DependencyProperty 12 | .Register("UserName", typeof (string), typeof (UserCredentialsViewModel)); 13 | public string UserName 14 | { 15 | get 16 | { 17 | return (string)GetValue(UserNameProperty); 18 | } 19 | set 20 | { 21 | SetValue(UserNameProperty, value); 22 | } 23 | } 24 | 25 | public static DependencyProperty PasswordProperty = DependencyProperty 26 | .Register("Password", typeof(string), typeof(UserCredentialsViewModel)); 27 | public string Password 28 | { 29 | get 30 | { 31 | return (string)GetValue(PasswordProperty); 32 | } 33 | set 34 | { 35 | SetValue(PasswordProperty, value); 36 | } 37 | } 38 | 39 | public string Caption { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/ViewModels/ReceiveMessagesCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Windows.Input; 4 | using System.Net; 5 | 6 | namespace Unite.UI.ViewModels 7 | { 8 | public class ReceiveMessagesCommand : ICommand 9 | { 10 | private Action _OnExecute; 11 | 12 | public ReceiveMessagesCommand(Action onExecute) 13 | { 14 | _OnExecute = onExecute; 15 | } 16 | 17 | public event EventHandler CanExecuteChanged; 18 | 19 | public void Execute(object parameter, Action webExceptionHandler) 20 | { 21 | if (_OnExecute != null) 22 | { 23 | try 24 | { 25 | _OnExecute(); 26 | } 27 | catch (WebException exception) 28 | { 29 | if (webExceptionHandler != null) 30 | webExceptionHandler(exception); 31 | else 32 | throw; 33 | } 34 | } 35 | } 36 | 37 | public void Execute(object parameter) 38 | { 39 | Execute(parameter, null); 40 | } 41 | 42 | public bool CanExecute(object parameter) 43 | { 44 | return true; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Utilities/ContactProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging; 6 | 7 | namespace Unite.UI.Utilities 8 | { 9 | public interface IContactProvider 10 | { 11 | Contact Get(IIdentity identity); 12 | void Add(Contact contact); 13 | } 14 | 15 | public class ContactProvider : IContactProvider 16 | { 17 | private List Contacts; 18 | 19 | public ContactProvider() 20 | { 21 | Contacts = new List(); 22 | } 23 | 24 | public Contact Get(IIdentity identity) 25 | { 26 | foreach(var contact in Contacts) 27 | { 28 | foreach(var contactIdentity in contact.Identities) 29 | { 30 | if(contactIdentity.Equals(identity)) return contact; 31 | } 32 | } 33 | 34 | return new Contact() 35 | { 36 | Identities = new[] {identity}, 37 | Name = identity.UserName 38 | }; 39 | } 40 | 41 | public void Add(Contact contact) 42 | { 43 | Contacts.Add(contact); 44 | } 45 | 46 | public void Clear() 47 | { 48 | Contacts.Clear(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Unite.Specs")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Unite.Specs")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f4c2aebd-c320-4d1c-b246-2220348c2d3a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Unite.Messaging")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Unite.Messaging")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("aad6cc69-9201-48b4-8958-a5b129c9afd6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Unite.TestHarness/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Unite.TestHarness")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Unite.TestHarness")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("751cbebd-12c7-4e49-8044-1ae780e99f2d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GoogleTalkPlugIn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GoogleTalkPlugIn")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("cebbd923-77df-4612-8643-101d463eb260")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("IronTwitterPlugIn")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("IronTwitterPlugIn")] 13 | [assembly: AssemblyCopyright("Copyright © 2009")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("692c986e-f34a-4ec7-b40f-7ad19a1f03b9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/New_Starting_Application_Specs/Starting_app_vanilla_with_messages.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using NUnit.Framework; 3 | using Rhino.Mocks; 4 | using Rhino.Mocks.Constraints; 5 | using SpecUnit; 6 | using StructureMap; 7 | using Unite.Messaging; 8 | using Unite.Messaging.Messages; 9 | using Unite.UI.ViewModels; 10 | 11 | namespace Unite.Specs.New_Starting_Application_Specs 12 | { 13 | [TestFixture] 14 | public class When_application_starts : no_cached_credentials_no_settings 15 | { 16 | protected override void Context() 17 | { 18 | FakeRepo.FakePluginFinder 19 | .Stub(x => x.GetAllPlugins()) 20 | .Return(new[] { typeof(IMessagingService) }); 21 | 22 | ViewModel = FakeRepo.GetMainView(); 23 | } 24 | 25 | protected override void Because() 26 | { 27 | ViewModel.Init(); 28 | } 29 | 30 | [Test] 31 | public void It_should_start_receiving_messages() 32 | { 33 | FakeRepo.FakeMessagePlugin.AssertWasCalled(x => x.StartReceiving()); 34 | } 35 | } 36 | 37 | public abstract class no_cached_credentials_no_settings 38 | { 39 | protected MainView ViewModel; 40 | protected ScenarioRepository FakeRepo; 41 | 42 | [TestFixtureSetUp] 43 | public void Setup() 44 | { 45 | FakeRepo = new ScenarioRepository(); 46 | 47 | Context(); 48 | Because(); 49 | } 50 | 51 | protected abstract void Because(); 52 | 53 | protected abstract void Context(); 54 | } 55 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Entities/ServiceInformation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Unite.Messaging.Entities 4 | { 5 | public class ServiceInformation : IServiceInformation 6 | { 7 | public string ServiceName 8 | { 9 | get; set; 10 | } 11 | 12 | public Guid ServiceID 13 | { 14 | get; set; 15 | } 16 | 17 | public override bool Equals(object obj) 18 | { 19 | return AreEqual(this, obj); 20 | } 21 | 22 | public bool Equals(ServiceInformation obj) 23 | { 24 | return AreEqual(this, obj); 25 | } 26 | 27 | public static bool AreEqual(object a, object b) 28 | { 29 | if (ReferenceEquals(null, a) || ReferenceEquals(null, b)) return false; 30 | if (ReferenceEquals(a, b)) return true; 31 | if (!(a is IServiceInformation) || !(b is IServiceInformation)) return false; 32 | return AreEqual((IServiceInformation) a, (IServiceInformation) b); 33 | } 34 | 35 | public static bool AreEqual(IServiceInformation a, IServiceInformation b) 36 | { 37 | if (ReferenceEquals(null, a) || ReferenceEquals(null, b)) return false; 38 | if (ReferenceEquals(a, b)) return true; 39 | return Equals(a.ServiceName, b.ServiceName) && a.ServiceID.Equals(b.ServiceID); 40 | } 41 | 42 | public override int GetHashCode() 43 | { 44 | unchecked 45 | { 46 | return ((ServiceName != null ? ServiceID.GetHashCode() : 0) * 397) ^ ServiceID.GetHashCode(); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/New_Starting_Application_Specs/FakePlugin.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using Unite.Messaging; 5 | using Unite.Messaging.Entities; 6 | using Unite.Messaging.Messages; 7 | using Unite.Messaging.Services; 8 | 9 | namespace Unite.Specs.New_Starting_Application_Specs 10 | { 11 | public class FakePlugin : IMessagingService 12 | { 13 | public event EventHandler AuthorizationFailed; 14 | public virtual event EventHandler CredentialsRequested; 15 | public event EventHandler MessagesReceived; 16 | 17 | public virtual bool CanAccept(Credentials credentials) 18 | { 19 | return true; 20 | } 21 | 22 | public virtual List GetMessages() 23 | { 24 | return new List(); 25 | } 26 | 27 | public virtual void SendMessage(IIdentity recipient, string message) 28 | { 29 | 30 | } 31 | 32 | public virtual void SetCredentials(Credentials credentials) 33 | { 34 | 35 | } 36 | 37 | public virtual bool CanFind(string address) 38 | { 39 | return true; 40 | } 41 | 42 | public virtual ServiceInformation GetInformation() 43 | { 44 | return new ServiceInformation(){ServiceID = Guid.NewGuid(), ServiceName = "Fake"}; 45 | } 46 | 47 | public virtual void StartReceiving() 48 | { 49 | 50 | } 51 | 52 | public virtual void StopReceiving() 53 | { 54 | 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Utilities/InlineUrls.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | 7 | namespace Unite.UI.Utilities 8 | { 9 | public static class InlineUris 10 | { 11 | //http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/ 12 | private const string URI_REGEX = 13 | @"\b(?:(?:https?|ftp|file)://|www\.|ftp\.)" 14 | + @"(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*" 15 | + @"(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[A-Z0-9+&@#/%=~_|$])";// (free-spacing, case insensitive) 16 | 17 | private static Regex _regex = new Regex(URI_REGEX, RegexOptions.IgnoreCase); 18 | 19 | public static List Get(string text) 20 | { 21 | var uris = new List(); 22 | 23 | if (string.IsNullOrEmpty(text)) 24 | return uris; 25 | 26 | Match match; 27 | int index = 0; 28 | while (true) 29 | { 30 | match = _regex.Match(text, index); 31 | if (match == Match.Empty) 32 | break; 33 | 34 | uris.Add(new InlineUri(text.Substring(match.Index, match.Length), match.Index, match.Length)); 35 | index = match.Index + match.Length; 36 | }; 37 | 38 | return uris; 39 | } 40 | } 41 | 42 | public class InlineUri : Uri 43 | { 44 | public int StartIndex { get; private set; } 45 | public int Length { get; private set; } 46 | 47 | public InlineUri(string uriString, int startIndex, int length) : base(uriString) 48 | { 49 | StartIndex = startIndex; 50 | Length = length; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/Application_running/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NUnit.Framework; 3 | using SpecUnit; 4 | using StructureMap; 5 | using Unite.Messaging.Messages; 6 | using Unite.UI.ViewModels; 7 | 8 | namespace Unite.Specs.Application_running.Managing_Plugins 9 | { 10 | [TestFixture] 11 | public class When_a_message_is_received_while_messages_already_exist : context 12 | { 13 | [Test] 14 | public void It_should_increase_the_number_of_viewable_messages_by_one() 15 | { 16 | Model.Messages.Count.ShouldEqual(2); 17 | } 18 | 19 | [Test] 20 | public void It_should_place_the_most_recent_message_at_the_top_of_the_list() 21 | { 22 | Model.Messages[0].TimeStamp.CompareTo(Model.Messages[1].TimeStamp).ShouldEqual(1); 23 | } 24 | 25 | protected override void Context() 26 | { 27 | Model = ObjectFactory.GetInstance(); 28 | Model.Init(); 29 | 30 | Model.Messages.Count.ShouldEqual(1); 31 | } 32 | 33 | protected override void Because() 34 | { 35 | Model.ReceiveMessage.Execute(null); 36 | } 37 | 38 | } 39 | 40 | public abstract class context 41 | { 42 | protected MainView Model; 43 | protected TestTwitterUtilities Utilities; 44 | 45 | 46 | [TestFixtureSetUp] 47 | public void Setup() 48 | { 49 | ContainerBootstrapper.BootstrapStructureMap(); 50 | 51 | Utilities = new TestTwitterUtilities(); 52 | ObjectFactory.EjectAllInstancesOf(); 53 | ObjectFactory.Inject(Utilities); 54 | 55 | Context(); 56 | Because(); 57 | } 58 | 59 | protected abstract void Because(); 60 | 61 | protected abstract void Context(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Unite.Setup/Unite.Setup.wixproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Debug 4 | x86 5 | 3.0 6 | {8092133e-60b2-4e7f-9575-5d7cd52fbf11} 7 | 2.0 8 | Unite.Setup 9 | Package 10 | $(MSBuildExtensionsPath)\Microsoft\WiX\v3.0\Wix.targets 11 | 12 | 13 | bin\$(Configuration)\ 14 | obj\$(Configuration)\ 15 | Debug 16 | 17 | 18 | bin\$(Configuration)\ 19 | obj\$(Configuration)\ 20 | 21 | 22 | 23 | 24 | 25 | 26 | Unite.UI 27 | {df1a7919-466c-4321-bfef-c3aab6bf4841} 28 | True 29 | 30 | 31 | 32 | 33 | $(WixExtDir)\WixUIExtension.dll 34 | 35 | 36 | 37 | 45 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Services/PluginFinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Reflection; 5 | using Unite.Messaging.Messages; 6 | 7 | namespace Unite.Messaging.Services 8 | { 9 | public class PluginFinder : IPluginFinder 10 | { 11 | public IEnumerable GetAllPlugins() 12 | { 13 | var mainExeDir = Environment.CurrentDirectory; 14 | var pluginDir = new DirectoryInfo(mainExeDir); 15 | var thisAssembly = Assembly.GetExecutingAssembly(); 16 | var entryAssembly = Assembly.GetEntryAssembly(); 17 | 18 | var result = new List(); 19 | 20 | if (entryAssembly == null) return new List(); 21 | 22 | foreach (var fileInfo in pluginDir.GetFiles("*.dll", SearchOption.TopDirectoryOnly)) 23 | { 24 | if (string.Compare(fileInfo.FullName, thisAssembly.Location, true) == 0) 25 | continue; 26 | if (string.Compare(fileInfo.FullName, entryAssembly.Location, true) == 0) 27 | continue; 28 | try 29 | { 30 | var assembly = Assembly.LoadFrom(fileInfo.FullName); 31 | foreach (var type in assembly.GetTypes()) 32 | { 33 | var found = false; 34 | foreach (var interfaceType in type.GetInterfaces()) 35 | { 36 | if (interfaceType == typeof(IMessagingService)) 37 | { 38 | result.Add(type); 39 | found = true; 40 | break; 41 | } 42 | } 43 | if (found) 44 | break; 45 | } 46 | } 47 | catch (Exception) 48 | { } 49 | } 50 | 51 | return result; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /IronTwit/IronTwit/Messaging/Entities/Identity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using Unite.Messaging.Entities; 6 | 7 | namespace Unite.Messaging 8 | { 9 | //Service specific (i.e. not a "Contact" which is a semantic grouping of IIdentities under one friendly name) 10 | //Service specific "contacts" are called Identities because that is the actual identity for the system 11 | //General identities are call contacts because they represent a single person to contact. 12 | public interface IIdentity 13 | { 14 | /// 15 | /// For Twitter, e.g. '@darkxanthos' 16 | /// For Email, e.g. 'darkxanthos@gmail.com' 17 | /// 18 | string UserName { get; } 19 | ServiceInformation ServiceInfo { get; } 20 | } 21 | 22 | public class Identity : IIdentity 23 | { 24 | public Identity(string userName, ServiceInformation serviceInformation) 25 | { 26 | UserName = userName; 27 | ServiceInfo = serviceInformation; 28 | } 29 | 30 | public string UserName { get; private set; } 31 | 32 | public ServiceInformation ServiceInfo { get; private set; } 33 | 34 | public override bool Equals(object obj) 35 | { 36 | if (ReferenceEquals(null, obj)) return false; 37 | if (ReferenceEquals(this, obj)) return true; 38 | if (obj.GetType() != typeof(Identity)) return false; 39 | return Equals((Identity)obj); 40 | } 41 | 42 | public bool Equals(Identity obj) 43 | { 44 | if (ReferenceEquals(null, obj)) return false; 45 | if (ReferenceEquals(this, obj)) return true; 46 | return Equals(obj.UserName, UserName) && Equals(obj.ServiceInfo, ServiceInfo); 47 | } 48 | 49 | public override int GetHashCode() 50 | { 51 | unchecked 52 | { 53 | return (UserName.GetHashCode() * 397) ^ ServiceInfo.GetHashCode(); 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/DraggableWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows; 3 | using System.Windows.Input; 4 | 5 | namespace Unite.UI 6 | { 7 | public class DraggableWindow : Window 8 | { 9 | private Point? _mouseDownPoint; 10 | private bool _dragging; 11 | 12 | protected Point _resizeMouseDownPoint; 13 | protected Size _mouseDownSize; 14 | protected bool _resizing; 15 | 16 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) 17 | { 18 | Console.WriteLine("DraggableWindow.OnMouseLeftButtonDown"); 19 | _mouseDownPoint = e.MouseDevice.GetPosition(null); 20 | 21 | base.OnMouseLeftButtonDown(e); 22 | } 23 | 24 | protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) 25 | { 26 | _mouseDownPoint = null; 27 | 28 | if (_dragging) 29 | { 30 | _dragging = false; 31 | ReleaseMouseCapture(); 32 | } 33 | 34 | base.OnMouseLeftButtonUp(e); 35 | } 36 | 37 | protected override void OnMouseMove(MouseEventArgs e) 38 | { 39 | if (e.LeftButton != MouseButtonState.Pressed || _mouseDownPoint == null || _resizing) 40 | { 41 | base.OnMouseMove(e); 42 | return; 43 | } 44 | 45 | var currentPosition = e.MouseDevice.GetPosition(null); 46 | var moveVector = Point.Subtract(currentPosition, (Point)_mouseDownPoint); 47 | 48 | if (_dragging) 49 | { 50 | DragWindow(e, moveVector); 51 | return; 52 | } 53 | 54 | if (moveVector.Length >= 3) //this is a drag 55 | { 56 | _dragging = true; 57 | CaptureMouse(); 58 | return; 59 | } 60 | 61 | base.OnMouseMove(e); 62 | } 63 | 64 | private void DragWindow(MouseEventArgs e, Vector dragVector) 65 | { 66 | var newPosition = PointToScreen(new Point(dragVector.X, dragVector.Y)); 67 | 68 | Left = newPosition.X; 69 | Top = newPosition.Y; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Unite.TestHarness/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading; 7 | using jabber.client; 8 | 9 | namespace Unite.TestHarness 10 | { 11 | class Program 12 | { 13 | private static ManualResetEvent done = new ManualResetEvent(false); 14 | static void Main(string[] args) 15 | { 16 | var client = new JabberClient(); 17 | 18 | client.AutoPresence = false; 19 | client.AutoRoster = false; 20 | client.AutoReconnect = -1; 21 | 22 | client.User = "herbstudent"; 23 | client.Password = "samhain8"; 24 | client.Server = "gmail.com"; 25 | client.Port = 5222; 26 | client.Resource = "Pidgin"; 27 | 28 | client.OnMessage += (s, e) => 29 | { 30 | Console.WriteLine("Message sent..."); 31 | }; 32 | 33 | client.OnAuthError += (s, e) => 34 | { 35 | Console.WriteLine("Auth Error: " + e.InnerText); 36 | client.Close(); 37 | }; 38 | 39 | client.OnAuthenticate += s => 40 | { 41 | Console.WriteLine("Authenticated..."); 42 | client.Message("darkxanthos@gmail.com", "Testing"); 43 | }; 44 | 45 | client.OnError += (s, e) => 46 | { 47 | Console.WriteLine("Error! " + e.Message); 48 | client.Close(); 49 | }; 50 | 51 | 52 | 53 | client.Connect(); 54 | 55 | done.WaitOne(); 56 | client.Close(); 57 | } 58 | 59 | static void client_OnError(object sender, Exception ex) 60 | { 61 | 62 | } 63 | 64 | static void client_OnMessage(object sender, jabber.protocol.client.Message msg) 65 | { 66 | throw new NotImplementedException(); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Resources; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | using System.Windows; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyTitle("Unite.UI")] 11 | [assembly: AssemblyDescription("")] 12 | [assembly: AssemblyConfiguration("")] 13 | [assembly: AssemblyCompany("")] 14 | [assembly: AssemblyProduct("Unite.UI")] 15 | [assembly: AssemblyCopyright("Copyright © 2009")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | [assembly: ComVisible(false)] 23 | 24 | //In order to begin building localizable applications, set 25 | //CultureYouAreCodingWith in your .csproj file 26 | //inside a . For example, if you are using US english 27 | //in your source files, set the to en-US. Then uncomment 28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in 29 | //the line below to match the UICulture setting in the project file. 30 | 31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] 32 | 33 | 34 | [assembly: ThemeInfo( 35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 36 | //(used if a resource is not found in the page, 37 | // or application resource dictionaries) 38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 39 | //(used if a resource is not found in the page, 40 | // app, or any theme specific resource dictionaries) 41 | )] 42 | 43 | 44 | // Version information for an assembly consists of the following four values: 45 | // 46 | // Major Version 47 | // Minor Version 48 | // Build Number 49 | // Revision 50 | // 51 | // You can specify all the values or you can default the Build and Revision Numbers 52 | // by using the '*' as shown below: 53 | // [assembly: AssemblyVersion("1.0.*")] 54 | [assembly: AssemblyVersion("1.0.0.0")] 55 | [assembly: AssemblyFileVersion("1.0.0.0")] 56 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Specs/New_Starting_Application_Specs/When_application_starts_receiving_with_no_valid_credentials.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using NUnit.Framework; 6 | using Rhino.Mocks; 7 | using Unite.Messaging; 8 | using Unite.Messaging.Entities; 9 | using Unite.Messaging.Messages; 10 | using Unite.UI.ViewModels; 11 | 12 | namespace Unite.Specs.New_Starting_Application_Specs 13 | { 14 | [TestFixture] 15 | public class When_messaging_service_needs_credentials : cached_credentials_no_settings 16 | { 17 | protected override void Context() 18 | { 19 | FakeRepo.FakePluginFinder 20 | .Stub(x => x.GetAllPlugins()) 21 | .Return(new[] { typeof(IMessagingService) }); 22 | 23 | FakeRepo.FakeContext 24 | .Stub(x => x.GetCredentials(null)) 25 | .Return(FakeRepo.CreateFakeCredentials()); 26 | 27 | ViewModel = FakeRepo.GetMainView(); 28 | } 29 | 30 | protected override void Because() 31 | { 32 | ViewModel.Init(); 33 | } 34 | 35 | [Test] 36 | public void It_should_ask_ui_for_credentials() 37 | { 38 | FakeRepo.FakeContext 39 | .AssertWasCalled(x => x.GetCredentials(null)); 40 | } 41 | } 42 | 43 | public class GetCredentialsPlugIn : FakePlugin 44 | { 45 | public override event EventHandler CredentialsRequested; 46 | 47 | public override void StartReceiving() 48 | { 49 | CredentialsRequested(this, new CredentialEventArgs()); 50 | } 51 | } 52 | 53 | public abstract class cached_credentials_no_settings 54 | { 55 | protected MainView ViewModel; 56 | protected ScenarioRepository FakeRepo; 57 | protected IMessagingService FakeMessagingPlugin; 58 | 59 | [TestFixtureSetUp] 60 | public void Setup() 61 | { 62 | FakeMessagingPlugin = new GetCredentialsPlugIn(); 63 | 64 | FakeRepo = new ScenarioRepository() 65 | { 66 | FakeMessagePlugin = FakeMessagingPlugin 67 | }; 68 | 69 | Context(); 70 | Because(); 71 | } 72 | 73 | protected abstract void Because(); 74 | 75 | protected abstract void Context(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/GoogleTalkDataAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using jabber.client; 6 | using jabber.protocol.client; 7 | 8 | namespace GoogleTalkPlugIn 9 | { 10 | public class GoogleTalkDataAccess 11 | { 12 | private readonly JabberClient _Client; 13 | public bool IsConnected; 14 | 15 | public GoogleTalkDataAccess() 16 | { 17 | var client = new JabberClient(); 18 | 19 | client.AutoLogin = true; 20 | client.AutoPresence = true; 21 | client.AutoRoster = false; 22 | client.AutoReconnect = 1; 23 | 24 | client.Server = "gmail.com"; 25 | client.Port = 5222; 26 | client.Resource = "Unit3"; 27 | 28 | client.OnConnect += (s, e) => 29 | { 30 | IsConnected = e.Connected; 31 | }; 32 | 33 | client.OnError += (s, e) => 34 | { 35 | throw new Exception(e.Message); 36 | }; 37 | client.OnAuthError += (s, e) => OnAuthError(s, null); 38 | client.OnMessage += (s, e) => 39 | { 40 | OnMessage(s, new GTalkMessageEventArgs(e.From.User, e.Body)); 41 | }; 42 | 43 | _Client = client; 44 | } 45 | 46 | public event EventHandler OnAuthError; 47 | public event EventHandler OnMessage; 48 | 49 | public void Message(string name, string message) 50 | { 51 | _Client.Message(name, message); 52 | } 53 | 54 | public void Login(string name, string password) 55 | { 56 | _Client.User = name; 57 | _Client.Password = password; 58 | _Connect(); 59 | } 60 | 61 | private void _Connect() 62 | { 63 | _Client.Connect(); 64 | } 65 | 66 | internal void Logoff() 67 | { 68 | _Client.Close(); 69 | } 70 | } 71 | 72 | public class GTalkMessageEventArgs : EventArgs 73 | { 74 | public GTalkMessageEventArgs(string user, string message) 75 | { 76 | Message = message; 77 | User = user; 78 | } 79 | 80 | public string Message; 81 | public string User; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /IronTwit/IronTwit/UI/Views/UserCredentials.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 46 | 53 | 54 | 55 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 |