├── .gitattributes ├── .gitignore ├── AutomaticUpdate.Client ├── AutomaticUpdate.Client.csproj ├── AutomaticUpdateClient.cs ├── Properties │ └── AssemblyInfo.cs └── UpdateInfo.cs ├── AutomaticUpdate.Update ├── AutomaticUpdate.Update.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── logo2.ico ├── BitChatApp ├── BitChatApp.csproj ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ └── Resources.resx ├── Resources │ ├── Attachment.png │ ├── FullNetwork.png │ ├── MessageNotification.wav │ ├── NoNetwork.png │ ├── PartialNetwork.png │ ├── change-photo.png │ ├── double-ticks.png │ ├── logo2.ico │ ├── message-failed.png │ ├── point-left.png │ ├── point-right.png │ ├── send message.png │ ├── single-tick.png │ └── waiting.png ├── UserControls │ ├── BitChatPanel.Designer.cs │ ├── BitChatPanel.cs │ ├── BitChatPanel.resx │ ├── ChatListItem.Designer.cs │ ├── ChatListItem.cs │ ├── ChatListItem.resx │ ├── ChatMessageFileItem.Designer.cs │ ├── ChatMessageFileItem.cs │ ├── ChatMessageFileItem.resx │ ├── ChatMessageInfoItem.Designer.cs │ ├── ChatMessageInfoItem.cs │ ├── ChatMessageInfoItem.resx │ ├── ChatMessageTextItem.Designer.cs │ ├── ChatMessageTextItem.cs │ ├── ChatMessageTextItem.resx │ ├── ChatMessageView.Designer.cs │ ├── ChatMessageView.cs │ ├── ChatMessageView.resx │ ├── CustomButton.cs │ ├── CustomListView.Designer.cs │ ├── CustomListView.cs │ ├── CustomListView.resx │ ├── CustomListViewItem.Designer.cs │ ├── CustomListViewItem.cs │ ├── CustomListViewItem.resx │ ├── CustomListViewPanel.Designer.cs │ ├── CustomListViewPanel.cs │ ├── CustomListViewPanel.resx │ ├── CustomPanel.Designer.cs │ ├── CustomPanel.cs │ ├── CustomPanel.resx │ ├── IChatMessageItem.cs │ ├── SharedFileItem.Designer.cs │ ├── SharedFileItem.cs │ ├── SharedFileItem.resx │ ├── UserListItem.Designer.cs │ ├── UserListItem.cs │ └── UserListItem.resx ├── app.manifest ├── frmAbout.Designer.cs ├── frmAbout.cs ├── frmAbout.resx ├── frmAddChat.Designer.cs ├── frmAddChat.cs ├── frmAddChat.resx ├── frmAddTracker.Designer.cs ├── frmAddTracker.cs ├── frmAddTracker.resx ├── frmChatProperties.Designer.cs ├── frmChatProperties.cs ├── frmChatProperties.resx ├── frmImageDialog.Designer.cs ├── frmImageDialog.cs ├── frmImageDialog.resx ├── frmImportPEM.Designer.cs ├── frmImportPEM.cs ├── frmImportPEM.resx ├── frmMain.Designer.cs ├── frmMain.cs ├── frmMain.resx ├── frmMessageInfo.Designer.cs ├── frmMessageInfo.cs ├── frmMessageInfo.resx ├── frmNetworkInfo.Designer.cs ├── frmNetworkInfo.cs ├── frmNetworkInfo.resx ├── frmPassword.Designer.cs ├── frmPassword.cs ├── frmPassword.resx ├── frmProfileManager.Designer.cs ├── frmProfileManager.cs ├── frmProfileManager.resx ├── frmProxyConfig.Designer.cs ├── frmProxyConfig.cs ├── frmProxyConfig.resx ├── frmRegister.Designer.cs ├── frmRegister.cs ├── frmRegister.resx ├── frmSettings.Designer.cs ├── frmSettings.cs ├── frmSettings.resx ├── frmShareFileSelection.Designer.cs ├── frmShareFileSelection.cs ├── frmShareFileSelection.resx ├── frmViewCertificate.Designer.cs ├── frmViewCertificate.cs ├── frmViewCertificate.resx ├── frmViewGroup.Designer.cs ├── frmViewGroup.cs ├── frmViewGroup.resx ├── frmViewProfile.Designer.cs ├── frmViewProfile.cs ├── frmViewProfile.resx ├── frmViewUserDetails.Designer.cs ├── frmViewUserDetails.cs ├── frmViewUserDetails.resx ├── frmWelcome.Designer.cs ├── frmWelcome.cs ├── frmWelcome.resx └── logo2.ico ├── BitChatAppMono ├── BitChatAppMono.csproj ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Resources │ ├── Attachment.png │ ├── FullNetwork.png │ ├── MessageNotification.wav │ ├── NoNetwork.png │ ├── PartialNetwork.png │ ├── change-photo.png │ ├── double-ticks.png │ ├── message-failed.png │ ├── point-left.png │ ├── point-right.png │ ├── send message.png │ ├── single-tick.png │ └── waiting.png ├── UserControls │ ├── BitChatPanel.Designer.cs │ ├── BitChatPanel.cs │ ├── BitChatPanel.resx │ ├── ChatListItem.Designer.cs │ ├── ChatListItem.cs │ ├── ChatListItem.resx │ ├── ChatMessageFileItem.Designer.cs │ ├── ChatMessageFileItem.cs │ ├── ChatMessageFileItem.resx │ ├── ChatMessageInfoItem.Designer.cs │ ├── ChatMessageInfoItem.cs │ ├── ChatMessageInfoItem.resx │ ├── ChatMessageTextItem.Designer.cs │ ├── ChatMessageTextItem.cs │ ├── ChatMessageTextItem.resx │ ├── ChatMessageView.Designer.cs │ ├── ChatMessageView.cs │ ├── ChatMessageView.resx │ ├── CustomButton.cs │ ├── CustomListView.Designer.cs │ ├── CustomListView.cs │ ├── CustomListView.resx │ ├── CustomListViewItem.Designer.cs │ ├── CustomListViewItem.cs │ ├── CustomListViewItem.resx │ ├── CustomListViewPanel.Designer.cs │ ├── CustomListViewPanel.cs │ ├── CustomListViewPanel.resx │ ├── CustomPanel.Designer.cs │ ├── CustomPanel.cs │ ├── CustomPanel.resx │ ├── IChatMessageItem.cs │ ├── SharedFileItem.Designer.cs │ ├── SharedFileItem.cs │ ├── SharedFileItem.resx │ ├── UserListItem.Designer.cs │ ├── UserListItem.cs │ └── UserListItem.resx ├── frmAbout.Designer.cs ├── frmAbout.cs ├── frmAbout.resx ├── frmAddChat.Designer.cs ├── frmAddChat.cs ├── frmAddChat.resx ├── frmAddTracker.Designer.cs ├── frmAddTracker.cs ├── frmAddTracker.resx ├── frmChatProperties.Designer.cs ├── frmChatProperties.cs ├── frmChatProperties.resx ├── frmImageDialog.Designer.cs ├── frmImageDialog.cs ├── frmImageDialog.resx ├── frmImportPEM.Designer.cs ├── frmImportPEM.cs ├── frmImportPEM.resx ├── frmMain.Designer.cs ├── frmMain.cs ├── frmMain.resx ├── frmMessageInfo.Designer.cs ├── frmMessageInfo.cs ├── frmMessageInfo.resx ├── frmNetworkInfo.Designer.cs ├── frmNetworkInfo.cs ├── frmNetworkInfo.resx ├── frmPassword.Designer.cs ├── frmPassword.cs ├── frmPassword.resx ├── frmProfileManager.Designer.cs ├── frmProfileManager.cs ├── frmProfileManager.resx ├── frmProxyConfig.Designer.cs ├── frmProxyConfig.cs ├── frmProxyConfig.resx ├── frmRegister.Designer.cs ├── frmRegister.cs ├── frmRegister.resx ├── frmSettings.Designer.cs ├── frmSettings.cs ├── frmSettings.resx ├── frmShareFileSelection.Designer.cs ├── frmShareFileSelection.cs ├── frmShareFileSelection.resx ├── frmViewCertificate.Designer.cs ├── frmViewCertificate.cs ├── frmViewCertificate.resx ├── frmViewGroup.Designer.cs ├── frmViewGroup.cs ├── frmViewGroup.resx ├── frmViewProfile.Designer.cs ├── frmViewProfile.cs ├── frmViewProfile.resx ├── frmViewUserDetails.Designer.cs ├── frmViewUserDetails.cs ├── frmViewUserDetails.resx ├── frmWelcome.Designer.cs ├── frmWelcome.cs ├── frmWelcome.resx ├── install-mono.sh ├── logo2.ico └── start.sh ├── BitChatAppSetup └── BitChatAppSetup.vdproj ├── BitChatClient.sln ├── BitChatCore ├── BitChat.cs ├── BitChatCore.csproj ├── BitChatException.cs ├── BitChatMessage.cs ├── BitChatNode.cs ├── BitChatProfile.cs ├── Debug.cs ├── FileSharing │ ├── SharedFile.cs │ └── SharedFileMetaData.cs ├── IDebug.cs ├── MessageItem.cs ├── MessageRecipient.cs ├── MessageStore.cs ├── Network │ ├── BitChatNetwork.cs │ ├── Connections │ │ ├── Connection.cs │ │ └── ConnectionManager.cs │ ├── KademliaDHT │ │ ├── DhtNode.cs │ │ ├── DhtRpcPacket.cs │ │ ├── IDhtNodeManager.cs │ │ ├── KBucket.cs │ │ ├── NodeContact.cs │ │ └── PeerEndPoint.cs │ ├── LocalPeerDiscovery.cs │ ├── PeerInfo.cs │ ├── SecureChannel │ │ ├── ISecureChannelSecurityManager.cs │ │ ├── SecureChannelClientStream.cs │ │ ├── SecureChannelException.cs │ │ ├── SecureChannelHandshakePacket.cs │ │ ├── SecureChannelServerStream.cs │ │ └── SecureChannelStream.cs │ ├── TcpRelayClient.cs │ ├── TcpRelayService.cs │ └── TrackerManager.cs └── Properties │ └── AssemblyInfo.cs ├── LICENSE ├── README.md └── References ├── TechnitiumLibrary.IO.dll ├── TechnitiumLibrary.Net.BitTorrent.dll ├── TechnitiumLibrary.Net.Firewall.dll ├── TechnitiumLibrary.Net.UPnP.dll ├── TechnitiumLibrary.Net.dll └── TechnitiumLibrary.Security.Cryptography.dll /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | [Bb]in/ 23 | [Oo]bj/ 24 | 25 | # Visual Studo 2015 cache/options directory 26 | .vs/ 27 | 28 | # MSTest test Results 29 | [Tt]est[Rr]esult*/ 30 | [Bb]uild[Ll]og.* 31 | 32 | # NUNIT 33 | *.VisualState.xml 34 | TestResult.xml 35 | 36 | # Build Results of an ATL Project 37 | [Dd]ebugPS/ 38 | [Rr]eleasePS/ 39 | dlldata.c 40 | 41 | *_i.c 42 | *_p.c 43 | *_i.h 44 | *.ilk 45 | *.meta 46 | *.obj 47 | *.pch 48 | *.pdb 49 | *.pgc 50 | *.pgd 51 | *.rsp 52 | *.sbr 53 | *.tlb 54 | *.tli 55 | *.tlh 56 | *.tmp 57 | *.tmp_proj 58 | *.log 59 | *.vspscc 60 | *.vssscc 61 | .builds 62 | *.pidb 63 | *.svclog 64 | *.scc 65 | 66 | # Chutzpah Test files 67 | _Chutzpah* 68 | 69 | # Visual C++ cache files 70 | ipch/ 71 | *.aps 72 | *.ncb 73 | *.opensdf 74 | *.sdf 75 | *.cachefile 76 | 77 | # Visual Studio profiler 78 | *.psess 79 | *.vsp 80 | *.vspx 81 | 82 | # TFS 2012 Local Workspace 83 | $tf/ 84 | 85 | # Guidance Automation Toolkit 86 | *.gpState 87 | 88 | # ReSharper is a .NET coding add-in 89 | _ReSharper*/ 90 | *.[Rr]e[Ss]harper 91 | *.DotSettings.user 92 | 93 | # JustCode is a .NET coding addin-in 94 | .JustCode 95 | 96 | # TeamCity is a build add-in 97 | _TeamCity* 98 | 99 | # DotCover is a Code Coverage Tool 100 | *.dotCover 101 | 102 | # NCrunch 103 | _NCrunch_* 104 | .*crunch*.local.xml 105 | 106 | # MightyMoose 107 | *.mm.* 108 | AutoTest.Net/ 109 | 110 | # Web workbench (sass) 111 | .sass-cache/ 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.[Pp]ublish.xml 131 | *.azurePubxml 132 | # TODO: Comment the next line if you want to checkin your web deploy settings 133 | # but database connection strings (with potential passwords) will be unencrypted 134 | *.pubxml 135 | *.publishproj 136 | 137 | # NuGet Packages 138 | *.nupkg 139 | # The packages folder can be ignored because of Package Restore 140 | **/packages/* 141 | # except build/, which is used as an MSBuild target. 142 | !**/packages/build/ 143 | # Uncomment if necessary however generally it will be regenerated when needed 144 | #!**/packages/repositories.config 145 | 146 | # Windows Azure Build Output 147 | csx/ 148 | *.build.csdef 149 | 150 | # Windows Store app package directory 151 | AppPackages/ 152 | 153 | # Others 154 | *.[Cc]ache 155 | ClientBin/ 156 | [Ss]tyle[Cc]op.* 157 | ~$* 158 | *~ 159 | *.dbmdl 160 | *.dbproj.schemaview 161 | *.pfx 162 | *.publishsettings 163 | node_modules/ 164 | bower_components/ 165 | 166 | # RIA/Silverlight projects 167 | Generated_Code/ 168 | 169 | # Backup & report files from converting an old project file 170 | # to a newer Visual Studio version. Backup files are not needed, 171 | # because we have git ;-) 172 | _UpgradeReport_Files/ 173 | Backup*/ 174 | UpgradeLog*.XML 175 | UpgradeLog*.htm 176 | 177 | # SQL Server files 178 | *.mdf 179 | *.ldf 180 | 181 | # Business Intelligence projects 182 | *.rdl.data 183 | *.bim.layout 184 | *.bim_*.settings 185 | 186 | # Microsoft Fakes 187 | FakesAssemblies/ 188 | 189 | # Node.js Tools for Visual Studio 190 | .ntvs_analysis.dat 191 | 192 | # Visual Studio 6 build log 193 | *.plg 194 | 195 | # Visual Studio 6 workspace options file 196 | *.opt 197 | -------------------------------------------------------------------------------- /AutomaticUpdate.Client/AutomaticUpdate.Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {0BC4EAC6-4A90-4126-900D-AB5EB691C3FD} 8 | Library 9 | Properties 10 | AutomaticUpdate.Client 11 | AutomaticUpdate.Client 12 | v4.0 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | full 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | true 32 | 33 | 34 | 35 | 36 | False 37 | ..\References\TechnitiumLibrary.IO.dll 38 | 39 | 40 | False 41 | ..\References\TechnitiumLibrary.Net.dll 42 | 43 | 44 | False 45 | ..\References\TechnitiumLibrary.Security.Cryptography.dll 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | -------------------------------------------------------------------------------- /AutomaticUpdate.Client/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("Automatic Update")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Technitium")] 12 | [assembly: AssemblyProduct("Technitium Automatic Update")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 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("517a96e8-324a-46ae-8955-615ce1bb5c8b")] 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.2.1.1")] 36 | [assembly: AssemblyFileVersion("1.2.1.1")] 37 | -------------------------------------------------------------------------------- /AutomaticUpdate.Client/UpdateInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.IO; 22 | using System.Text; 23 | using TechnitiumLibrary.IO; 24 | using TechnitiumLibrary.Security.Cryptography; 25 | 26 | namespace AutomaticUpdate.Client 27 | { 28 | public class UpdateInfo : EventArgs, IWriteStream 29 | { 30 | #region variables 31 | 32 | string _updateVersion; 33 | Uri _downloadURI; 34 | long _downloadSize; 35 | Signature _signature; 36 | 37 | #endregion 38 | 39 | #region constructor 40 | 41 | public UpdateInfo(string updateVersion, Uri downloadURI, long downloadSize, Signature signature) 42 | { 43 | _updateVersion = updateVersion; 44 | _downloadURI = downloadURI; 45 | _downloadSize = downloadSize; 46 | _signature = signature; 47 | 48 | if (_signature.SigningCertificate.Capability != CertificateCapability.SignDocument) 49 | throw new Exception("Signing certificate is not capable to sign files."); 50 | } 51 | 52 | public UpdateInfo(Stream s) 53 | { 54 | BinaryReader bR = new BinaryReader(s); 55 | 56 | if (Encoding.ASCII.GetString(bR.ReadBytes(2)) != "UI") 57 | throw new Exception("Invalid UpdateInfo format."); 58 | 59 | switch (bR.ReadByte()) //version 60 | { 61 | case 1: 62 | _updateVersion = Encoding.ASCII.GetString(bR.ReadBytes(bR.ReadByte())); 63 | _downloadURI = new Uri(Encoding.ASCII.GetString(bR.ReadBytes(bR.ReadByte()))); 64 | _downloadSize = bR.ReadInt64(); 65 | _signature = new Signature(bR.BaseStream); 66 | 67 | if (_signature.SigningCertificate.Capability != CertificateCapability.SignDocument) 68 | throw new Exception("Signing certificate is not capable to sign files."); 69 | 70 | break; 71 | 72 | default: 73 | throw new Exception("UpdateInfo version not supported."); 74 | } 75 | } 76 | 77 | #endregion 78 | 79 | #region public 80 | 81 | public bool IsUpdateAvailable(string currentVersion) 82 | { 83 | string[] uVer = _updateVersion.Split(new char[] { '.' }); 84 | string[] cVer = currentVersion.Split(new char[] { '.' }); 85 | 86 | int x = uVer.Length; 87 | if (x > cVer.Length) 88 | x = cVer.Length; 89 | 90 | for (int i = 0; i < x; i++) 91 | { 92 | if (Convert.ToInt32(uVer[i]) > Convert.ToInt32(cVer[i])) 93 | return true; 94 | else if (Convert.ToInt32(uVer[i]) < Convert.ToInt32(cVer[i])) 95 | return false; 96 | } 97 | 98 | if (uVer.Length > cVer.Length) 99 | { 100 | for (int i = x; i < uVer.Length; i++) 101 | { 102 | if (Convert.ToInt32(uVer[i]) > 0) 103 | return true; 104 | } 105 | } 106 | 107 | return false; 108 | } 109 | 110 | #endregion 111 | 112 | #region IWriteStream 113 | 114 | public void WriteTo(Stream s) 115 | { 116 | s.Write(Encoding.ASCII.GetBytes("UI"), 0, 2); //format 117 | s.WriteByte((byte)1); //version 118 | 119 | s.WriteByte(Convert.ToByte(_updateVersion.Length)); 120 | s.Write(Encoding.ASCII.GetBytes(_updateVersion), 0, _updateVersion.Length); 121 | 122 | s.WriteByte(Convert.ToByte(_downloadURI.AbsoluteUri.Length)); 123 | s.Write(Encoding.ASCII.GetBytes(_downloadURI.AbsoluteUri), 0, _downloadURI.AbsoluteUri.Length); 124 | 125 | s.Write(BitConverter.GetBytes(_downloadSize), 0, 8); 126 | _signature.WriteTo(s); 127 | } 128 | 129 | #endregion 130 | 131 | #region properties 132 | 133 | public string UpdateVersion 134 | { get { return _updateVersion; } } 135 | 136 | public Uri DownloadURI 137 | { get { return _downloadURI; } } 138 | 139 | public long DownloadSize 140 | { get { return _downloadSize; } } 141 | 142 | public Signature DownloadSignature 143 | { get { return _signature; } } 144 | 145 | #endregion 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /AutomaticUpdate.Update/AutomaticUpdate.Update.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {1A335105-2DA8-4143-A8CB-66A2C6FC1F00} 8 | WinExe 9 | Properties 10 | AutomaticUpdate.Update 11 | update 12 | v4.0 13 | 512 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | full 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | true 34 | 35 | 36 | logo2.ico 37 | 38 | 39 | 40 | 41 | 42 | False 43 | ..\References\TechnitiumLibrary.IO.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 61 | -------------------------------------------------------------------------------- /AutomaticUpdate.Update/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.IO; 22 | using System.Reflection; 23 | using System.Threading; 24 | using System.Windows.Forms; 25 | using TechnitiumLibrary.IO; 26 | 27 | namespace AutomaticUpdate.Update 28 | { 29 | static class Program 30 | { 31 | [STAThread] 32 | static void Main(string[] args) 33 | { 34 | Application.EnableVisualStyles(); 35 | Application.SetCompatibleTextRenderingDefault(false); 36 | 37 | #region wait for running instance to exit 38 | 39 | do 40 | { 41 | bool createdNewMutex; 42 | 43 | Mutex app = new Mutex(true, args[0], out createdNewMutex); 44 | 45 | app.Dispose(); 46 | 47 | if (createdNewMutex) 48 | break; 49 | 50 | Thread.Sleep(1000); 51 | } 52 | while (true); 53 | 54 | 55 | #endregion 56 | 57 | try 58 | { 59 | string pkgFile; 60 | 61 | switch (Environment.OSVersion.Platform) 62 | { 63 | case PlatformID.Win32NT: 64 | pkgFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "").Replace("/", "\\")), "update.pkg"); 65 | break; 66 | 67 | case PlatformID.Unix: 68 | pkgFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file://", "")), "update.pkg"); 69 | break; 70 | 71 | default: 72 | throw new Exception("Platform not supported."); 73 | } 74 | 75 | using (Package package = new Package(pkgFile, PackageMode.Open)) 76 | { 77 | package.ExtractAll(ExtractLocation.Custom, args[1], true); 78 | } 79 | 80 | MessageBox.Show("Update was installed successfully. Click OK to continue.", "Update Installed - Technitium Automatic Update", MessageBoxButtons.OK, MessageBoxIcon.Information); 81 | } 82 | catch (Exception ex) 83 | { 84 | MessageBox.Show("Error occured while updating application:\r\n\r\n" + ex.Message + "\r\n\r\nChanges were automatically rolled back.", "Update Error - Technitium Automatic Update", MessageBoxButtons.OK, MessageBoxIcon.Error); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /AutomaticUpdate.Update/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("Automatic Update")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Technitium")] 12 | [assembly: AssemblyProduct("Technitium Automatic Update")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 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("28d8f644-e646-4eff-9a0b-fbe9f30e0ac3")] 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.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /AutomaticUpdate.Update/logo2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/AutomaticUpdate.Update/logo2.ico -------------------------------------------------------------------------------- /BitChatApp/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("Bit Chat")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Technitium")] 12 | [assembly: AssemblyProduct("Bit Chat")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 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("de6e050c-beb4-4c19-b756-3622511a9dc1")] 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("4.6.3.0")] 36 | [assembly: AssemblyFileVersion("4.6.3.0")] 37 | -------------------------------------------------------------------------------- /BitChatApp/Resources/Attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/Attachment.png -------------------------------------------------------------------------------- /BitChatApp/Resources/FullNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/FullNetwork.png -------------------------------------------------------------------------------- /BitChatApp/Resources/MessageNotification.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/MessageNotification.wav -------------------------------------------------------------------------------- /BitChatApp/Resources/NoNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/NoNetwork.png -------------------------------------------------------------------------------- /BitChatApp/Resources/PartialNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/PartialNetwork.png -------------------------------------------------------------------------------- /BitChatApp/Resources/change-photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/change-photo.png -------------------------------------------------------------------------------- /BitChatApp/Resources/double-ticks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/double-ticks.png -------------------------------------------------------------------------------- /BitChatApp/Resources/logo2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/logo2.ico -------------------------------------------------------------------------------- /BitChatApp/Resources/message-failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/message-failed.png -------------------------------------------------------------------------------- /BitChatApp/Resources/point-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/point-left.png -------------------------------------------------------------------------------- /BitChatApp/Resources/point-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/point-right.png -------------------------------------------------------------------------------- /BitChatApp/Resources/send message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/send message.png -------------------------------------------------------------------------------- /BitChatApp/Resources/single-tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/single-tick.png -------------------------------------------------------------------------------- /BitChatApp/Resources/waiting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/Resources/waiting.png -------------------------------------------------------------------------------- /BitChatApp/UserControls/ChatMessageInfoItem.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class ChatMessageInfoItem 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); 34 | this.copyInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 36 | this.contextMenuStrip1.SuspendLayout(); 37 | this.SuspendLayout(); 38 | // 39 | // label1 40 | // 41 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 42 | | System.Windows.Forms.AnchorStyles.Right))); 43 | this.label1.AutoEllipsis = true; 44 | this.label1.AutoSize = true; 45 | this.label1.BackColor = System.Drawing.Color.Azure; 46 | this.label1.ContextMenuStrip = this.contextMenuStrip1; 47 | this.label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 48 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 49 | this.label1.Location = new System.Drawing.Point(0, 6); 50 | this.label1.Name = "label1"; 51 | this.label1.Padding = new System.Windows.Forms.Padding(3); 52 | this.label1.Size = new System.Drawing.Size(116, 20); 53 | this.label1.TabIndex = 0; 54 | this.label1.Text = "Sample Info Message"; 55 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 56 | // 57 | // contextMenuStrip1 58 | // 59 | this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 60 | this.copyInfoToolStripMenuItem}); 61 | this.contextMenuStrip1.Name = "contextMenuStrip1"; 62 | this.contextMenuStrip1.Size = new System.Drawing.Size(127, 26); 63 | // 64 | // copyInfoToolStripMenuItem 65 | // 66 | this.copyInfoToolStripMenuItem.Name = "copyInfoToolStripMenuItem"; 67 | this.copyInfoToolStripMenuItem.Size = new System.Drawing.Size(126, 22); 68 | this.copyInfoToolStripMenuItem.Text = "Copy Info"; 69 | this.copyInfoToolStripMenuItem.Click += new System.EventHandler(this.copyInfoToolStripMenuItem_Click); 70 | // 71 | // ChatMessageInfoItem 72 | // 73 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 74 | this.BackColor = System.Drawing.Color.Transparent; 75 | this.ContextMenuStrip = this.contextMenuStrip1; 76 | this.Controls.Add(this.label1); 77 | this.Name = "ChatMessageInfoItem"; 78 | this.Size = new System.Drawing.Size(600, 32); 79 | this.contextMenuStrip1.ResumeLayout(false); 80 | this.ResumeLayout(false); 81 | this.PerformLayout(); 82 | 83 | } 84 | 85 | #endregion 86 | 87 | private System.Windows.Forms.Label label1; 88 | private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; 89 | private System.Windows.Forms.ToolStripMenuItem copyInfoToolStripMenuItem; 90 | private System.Windows.Forms.ToolTip toolTip1; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/ChatMessageInfoItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using System; 22 | using System.Drawing; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp.UserControls 26 | { 27 | public partial class ChatMessageInfoItem : CustomListViewItem, IChatMessageItem 28 | { 29 | #region variables 30 | 31 | MessageItem _message; 32 | 33 | #endregion 34 | 35 | #region constructor 36 | 37 | public ChatMessageInfoItem(MessageItem message) 38 | { 39 | InitializeComponent(); 40 | 41 | _message = message; 42 | 43 | if (string.IsNullOrEmpty(_message.Message)) 44 | { 45 | label1.Text = _message.MessageDate.ToLocalTime().ToString("dddd, MMMM d, yyyy"); 46 | } 47 | else 48 | { 49 | label1.Text = _message.Message; 50 | toolTip1.SetToolTip(label1, _message.MessageDate.ToLocalTime().ToString()); 51 | } 52 | 53 | OnResize(EventArgs.Empty); 54 | } 55 | 56 | #endregion 57 | 58 | #region form code 59 | 60 | protected override void OnResize(EventArgs e) 61 | { 62 | base.OnResize(e); 63 | 64 | if (label1 != null) 65 | { 66 | this.SuspendLayout(); 67 | 68 | if (label1.Width > (this.Width - 4)) 69 | { 70 | label1.AutoSize = false; 71 | label1.Left = 2; 72 | label1.Width = this.Width - 4; 73 | 74 | Size msgSize = TextRenderer.MeasureText(label1.Text, label1.Font, new Size(label1.Width - 3 - 3, int.MaxValue), TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); 75 | 76 | label1.Height = msgSize.Height + 3 + 3; 77 | this.Height = label1.Height + 6 + 6; 78 | } 79 | else 80 | { 81 | label1.AutoSize = true; 82 | label1.Left = (this.Width - label1.Width) / 2; 83 | } 84 | 85 | this.ResumeLayout(); 86 | } 87 | 88 | this.Refresh(); 89 | } 90 | 91 | private void copyInfoToolStripMenuItem_Click(object sender, EventArgs e) 92 | { 93 | try 94 | { 95 | if (string.IsNullOrEmpty(_message.Message)) 96 | Clipboard.SetText(label1.Text); 97 | else 98 | Clipboard.SetText("[" + _message.MessageDate.ToString("d MMM, yyyy HH:mm:ss") + "] " + label1.Text); 99 | } 100 | catch 101 | { } 102 | } 103 | 104 | #endregion 105 | 106 | #region properties 107 | 108 | public MessageItem Message 109 | { get { return _message; } } 110 | 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomButton.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Drawing; 23 | using System.Text; 24 | using System.Windows.Forms; 25 | 26 | namespace BitChatApp.UserControls 27 | { 28 | public class CustomButton : PictureBox 29 | { 30 | #region variables 31 | 32 | Image _image; 33 | 34 | #endregion 35 | 36 | #region constructor 37 | 38 | public CustomButton() 39 | : base() 40 | { 41 | this.SizeMode = PictureBoxSizeMode.AutoSize; 42 | } 43 | 44 | #endregion 45 | 46 | #region protected 47 | 48 | protected override void OnCreateControl() 49 | { 50 | base.OnCreateControl(); 51 | 52 | _image = this.Image; 53 | } 54 | 55 | protected override void OnMouseEnter(EventArgs e) 56 | { 57 | base.OnMouseEnter(e); 58 | 59 | base.Image = this.ImageHover; 60 | } 61 | 62 | protected override void OnMouseLeave(EventArgs e) 63 | { 64 | base.OnMouseLeave(e); 65 | 66 | this.Image = _image; 67 | } 68 | 69 | protected override void OnMouseDown(MouseEventArgs e) 70 | { 71 | base.OnMouseDown(e); 72 | 73 | this.Image = this.ImageMouseDown; 74 | } 75 | 76 | protected override void OnMouseUp(MouseEventArgs e) 77 | { 78 | base.OnMouseUp(e); 79 | 80 | this.Image = _image; 81 | } 82 | 83 | #endregion 84 | 85 | #region properties 86 | 87 | public Image ImageHover 88 | { get; set; } 89 | 90 | public Image ImageMouseDown 91 | { get; set; } 92 | 93 | #endregion 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomListView.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomListView 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // CustomListView 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.AutoScroll = true; 38 | this.BackColor = System.Drawing.Color.White; 39 | this.Name = "CustomListView"; 40 | this.Size = new System.Drawing.Size(262, 257); 41 | this.ResumeLayout(false); 42 | 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomListViewItem.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomListViewItem 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // CustomListViewItem 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "CustomListViewItem"; 38 | this.Size = new System.Drawing.Size(167, 77); 39 | this.Load += new System.EventHandler(this.CustomListViewItem_Load); 40 | this.ResumeLayout(false); 41 | 42 | } 43 | 44 | #endregion 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomListViewItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Drawing; 22 | using System.Windows.Forms; 23 | 24 | namespace BitChatApp.UserControls 25 | { 26 | public partial class CustomListViewItem : UserControl 27 | { 28 | #region event 29 | 30 | public event EventHandler SortList; 31 | 32 | #endregion 33 | 34 | #region variables 35 | 36 | const int BORDER_SIZE = 1; 37 | 38 | bool _selected = false; 39 | 40 | #endregion 41 | 42 | #region constructor 43 | 44 | public CustomListViewItem() 45 | { 46 | InitializeComponent(); 47 | } 48 | 49 | #endregion 50 | 51 | #region private 52 | 53 | private void CustomListViewItem_Load(object sender, EventArgs e) 54 | { 55 | foreach (Control ctrl in Controls) 56 | { 57 | ctrl.Click += ctrl_Click; 58 | ctrl.DoubleClick += ctrl_DoubleClick; 59 | ctrl.MouseUp += ctrl_MouseUp; 60 | ctrl.MouseLeave += ctrl_MouseLeave; 61 | ctrl.MouseEnter += ctrl_MouseEnter; 62 | ctrl.KeyDown += ctrl_KeyDown; 63 | ctrl.KeyUp += ctrl_KeyUp; 64 | ctrl.KeyPress += ctrl_KeyPress; 65 | } 66 | } 67 | 68 | private void ctrl_Click(object sender, EventArgs e) 69 | { 70 | OnClick(EventArgs.Empty); 71 | } 72 | 73 | private void ctrl_DoubleClick(object sender, EventArgs e) 74 | { 75 | OnDoubleClick(EventArgs.Empty); 76 | } 77 | 78 | private void ctrl_MouseUp(object sender, MouseEventArgs e) 79 | { 80 | if (sender != this) 81 | { 82 | Control obj = sender as Control; 83 | e = new MouseEventArgs(e.Button, e.Clicks, obj.Location.X + e.X, obj.Location.Y + e.Y, e.Delta); 84 | } 85 | 86 | OnMouseUp(e); 87 | } 88 | 89 | private void ctrl_MouseEnter(object sender, EventArgs e) 90 | { 91 | OnMouseEnter(e); 92 | } 93 | 94 | private void ctrl_MouseLeave(object sender, EventArgs e) 95 | { 96 | OnMouseLeave(e); 97 | } 98 | 99 | private void ctrl_KeyPress(object sender, KeyPressEventArgs e) 100 | { 101 | OnKeyPress(e); 102 | } 103 | 104 | private void ctrl_KeyUp(object sender, KeyEventArgs e) 105 | { 106 | OnKeyUp(e); 107 | } 108 | 109 | private void ctrl_KeyDown(object sender, KeyEventArgs e) 110 | { 111 | OnKeyDown(e); 112 | } 113 | 114 | #endregion 115 | 116 | #region protected 117 | 118 | protected virtual void OnSelected() 119 | { } 120 | 121 | protected virtual void OnMouseOver(bool hovering) 122 | { } 123 | 124 | protected override void OnPaint(PaintEventArgs e) 125 | { 126 | base.OnPaint(e); 127 | 128 | ControlPaint.DrawBorder(e.Graphics, ClientRectangle, 129 | SeparatorColor, 0, ButtonBorderStyle.Solid, 130 | SeparatorColor, 0, ButtonBorderStyle.Solid, 131 | SeparatorColor, 0, ButtonBorderStyle.Solid, 132 | SeparatorColor, BORDER_SIZE, ButtonBorderStyle.Solid); 133 | } 134 | 135 | protected override void OnMouseEnter(EventArgs e) 136 | { 137 | if (this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) 138 | { 139 | base.OnMouseEnter(e); 140 | OnMouseOver(true); 141 | } 142 | } 143 | 144 | protected override void OnMouseLeave(EventArgs e) 145 | { 146 | if (!this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) 147 | { 148 | base.OnMouseLeave(e); 149 | OnMouseOver(false); 150 | } 151 | } 152 | 153 | protected void SortListView() 154 | { 155 | if (SortList != null) 156 | SortList(this, EventArgs.Empty); 157 | } 158 | 159 | #endregion 160 | 161 | #region properties 162 | 163 | public Color SeparatorColor 164 | { set; get; } 165 | 166 | public bool Selected 167 | { 168 | get { return _selected; } 169 | set 170 | { 171 | if (_selected != value) 172 | { 173 | _selected = value; 174 | 175 | this.SuspendLayout(); 176 | 177 | OnSelected(); 178 | 179 | this.ResumeLayout(); 180 | } 181 | } 182 | } 183 | 184 | #endregion 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomListViewPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomListViewPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.customListView1 = new BitChatApp.UserControls.CustomListView(); 32 | this.panel2.SuspendLayout(); 33 | this.SuspendLayout(); 34 | // 35 | // panel2 36 | // 37 | this.panel2.Controls.Add(this.customListView1); 38 | // 39 | // customListView1 40 | // 41 | this.customListView1.AutoScroll = true; 42 | this.customListView1.AutoScrollToBottom = false; 43 | this.customListView1.BackColor = System.Drawing.Color.White; 44 | this.customListView1.BorderColor = System.Drawing.Color.Empty; 45 | this.customListView1.Dock = System.Windows.Forms.DockStyle.Fill; 46 | this.customListView1.Location = new System.Drawing.Point(0, 0); 47 | this.customListView1.Name = "customListView1"; 48 | this.customListView1.SeparatorColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(223))))); 49 | this.customListView1.Size = new System.Drawing.Size(297, 121); 50 | this.customListView1.TabIndex = 4; 51 | this.customListView1.ItemClick += new System.EventHandler(this.customListView1_ItemClick); 52 | this.customListView1.ItemDoubleClick += new System.EventHandler(this.customListView1_ItemDoubleClick); 53 | this.customListView1.ItemMouseUp += new System.Windows.Forms.MouseEventHandler(this.customListView1_ItemMouseUp); 54 | this.customListView1.ItemKeyDown += new System.Windows.Forms.KeyEventHandler(this.customListView1_ItemKeyDown); 55 | this.customListView1.ItemKeyUp += new System.Windows.Forms.KeyEventHandler(this.customListView1_ItemKeyUp); 56 | this.customListView1.ItemKeyPress += new System.Windows.Forms.KeyPressEventHandler(this.customListView1_ItemKeyPress); 57 | // 58 | // CustomListView2 59 | // 60 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 61 | this.Name = "CustomListView2"; 62 | this.panel2.ResumeLayout(false); 63 | this.ResumeLayout(false); 64 | 65 | } 66 | 67 | #endregion 68 | 69 | private CustomListView customListView1; 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomListViewPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Windows.Forms; 22 | 23 | namespace BitChatApp.UserControls 24 | { 25 | public partial class CustomListViewPanel : CustomPanel 26 | { 27 | #region events 28 | 29 | public event EventHandler ItemClick; 30 | public event EventHandler ItemDoubleClick; 31 | public event MouseEventHandler ItemMouseUp; 32 | public event KeyEventHandler ItemKeyDown; 33 | public event KeyEventHandler ItemKeyUp; 34 | public event KeyPressEventHandler ItemKeyPress; 35 | 36 | #endregion 37 | 38 | #region constructor 39 | 40 | public CustomListViewPanel() 41 | { 42 | InitializeComponent(); 43 | } 44 | 45 | #endregion 46 | 47 | #region public 48 | 49 | public CustomListViewItem AddItem(CustomListViewItem item) 50 | { 51 | return customListView1.AddItem(item); 52 | } 53 | 54 | public bool RemoveItem(CustomListViewItem item) 55 | { 56 | return customListView1.RemoveItem(item); 57 | } 58 | 59 | public void RemoveAllItems() 60 | { 61 | customListView1.RemoveAllItems(); 62 | } 63 | 64 | #endregion 65 | 66 | #region private 67 | 68 | private void customListView1_ItemClick(object sender, EventArgs e) 69 | { 70 | if (ItemClick != null) 71 | ItemClick(sender, e); 72 | } 73 | 74 | private void customListView1_ItemDoubleClick(object sender, EventArgs e) 75 | { 76 | if (ItemDoubleClick != null) 77 | ItemDoubleClick(sender, e); 78 | } 79 | 80 | private void customListView1_ItemKeyDown(object sender, KeyEventArgs e) 81 | { 82 | if (ItemKeyDown != null) 83 | ItemKeyDown(sender, e); 84 | } 85 | 86 | private void customListView1_ItemKeyPress(object sender, KeyPressEventArgs e) 87 | { 88 | if (ItemKeyPress != null) 89 | ItemKeyPress(sender, e); 90 | } 91 | 92 | private void customListView1_ItemKeyUp(object sender, KeyEventArgs e) 93 | { 94 | if (ItemKeyUp != null) 95 | ItemKeyUp(sender, e); 96 | } 97 | 98 | private void customListView1_ItemMouseUp(object sender, MouseEventArgs e) 99 | { 100 | if (ItemMouseUp != null) 101 | ItemMouseUp(sender, e); 102 | } 103 | 104 | #endregion 105 | 106 | #region properties 107 | 108 | public CustomListViewItem SelectedItem 109 | { get { return customListView1.SelectedItem; } } 110 | 111 | public int SeperatorSize 112 | { 113 | get { return customListView1.Padding.Top; } 114 | set { customListView1.Padding = new Padding(value, value, value, 0); } 115 | } 116 | 117 | public ControlCollection Items 118 | { get { return customListView1.Controls; } } 119 | 120 | public bool SortItems 121 | { 122 | get { return customListView1.SortItems; } 123 | set { customListView1.SortItems = value; } 124 | } 125 | 126 | #endregion 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.panel1 = new System.Windows.Forms.Panel(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.panel2 = new System.Windows.Forms.Panel(); 34 | this.panel1.SuspendLayout(); 35 | this.SuspendLayout(); 36 | // 37 | // panel1 38 | // 39 | this.panel1.BackColor = System.Drawing.Color.WhiteSmoke; 40 | this.panel1.Controls.Add(this.label1); 41 | this.panel1.Dock = System.Windows.Forms.DockStyle.Top; 42 | this.panel1.Location = new System.Drawing.Point(1, 1); 43 | this.panel1.Name = "panel1"; 44 | this.panel1.Size = new System.Drawing.Size(297, 25); 45 | this.panel1.TabIndex = 2; 46 | // 47 | // label1 48 | // 49 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 50 | | System.Windows.Forms.AnchorStyles.Right))); 51 | this.label1.AutoEllipsis = true; 52 | this.label1.Font = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 53 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(67)))), ((int)(((byte)(74)))), ((int)(((byte)(84))))); 54 | this.label1.Location = new System.Drawing.Point(5, 2); 55 | this.label1.Name = "label1"; 56 | this.label1.Size = new System.Drawing.Size(287, 21); 57 | this.label1.TabIndex = 2; 58 | this.label1.Text = "Title"; 59 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 60 | // 61 | // panel2 62 | // 63 | this.panel2.BackColor = System.Drawing.Color.White; 64 | this.panel2.Location = new System.Drawing.Point(1, 27); 65 | this.panel2.Name = "panel2"; 66 | this.panel2.Size = new System.Drawing.Size(297, 121); 67 | this.panel2.TabIndex = 3; 68 | // 69 | // CustomPanel 70 | // 71 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 72 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 73 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(223))))); 74 | this.Controls.Add(this.panel2); 75 | this.Controls.Add(this.panel1); 76 | this.Name = "CustomPanel"; 77 | this.Padding = new System.Windows.Forms.Padding(1, 1, 2, 2); 78 | this.Size = new System.Drawing.Size(300, 150); 79 | this.panel1.ResumeLayout(false); 80 | this.ResumeLayout(false); 81 | 82 | } 83 | 84 | #endregion 85 | 86 | private System.Windows.Forms.Panel panel1; 87 | private System.Windows.Forms.Label label1; 88 | protected System.Windows.Forms.Panel panel2; 89 | 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/CustomPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Drawing; 24 | using System.Text; 25 | using System.Windows.Forms; 26 | using System.ComponentModel.Design; 27 | 28 | namespace BitChatApp.UserControls 29 | { 30 | [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] 31 | public partial class CustomPanel : UserControl 32 | { 33 | #region variables 34 | 35 | const int BORDER_SIZE = 1; 36 | 37 | Color BorderColor = Color.FromArgb(224, 224, 223); 38 | Color BorderColorShadow = Color.FromArgb(199, 199, 198); 39 | 40 | #endregion 41 | 42 | #region constructor 43 | 44 | public CustomPanel() 45 | { 46 | InitializeComponent(); 47 | } 48 | 49 | #endregion 50 | 51 | #region private 52 | 53 | protected override void OnPaint(PaintEventArgs e) 54 | { 55 | base.OnPaint(e); 56 | 57 | ControlPaint.DrawBorder(e.Graphics, ClientRectangle, 58 | BorderColor, 0, ButtonBorderStyle.Solid, 59 | BorderColor, 0, ButtonBorderStyle.Solid, 60 | BorderColorShadow, BORDER_SIZE * 2, ButtonBorderStyle.Solid, 61 | BorderColorShadow, BORDER_SIZE * 2, ButtonBorderStyle.Solid); 62 | 63 | ControlPaint.DrawBorder(e.Graphics, ClientRectangle, 64 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid, 65 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid, 66 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid, 67 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid); 68 | } 69 | 70 | protected override void OnResize(EventArgs e) 71 | { 72 | if (panel1.Height == 0) 73 | panel2.Size = new Size(this.Width - 1 - 2, this.Height - 1 - 2); 74 | else 75 | panel2.Size = new Size(this.Width - 1 - 2, this.Height - panel1.Height - 1 - 1 - 2); 76 | 77 | base.OnResize(e); 78 | 79 | this.Refresh(); 80 | } 81 | 82 | #endregion 83 | 84 | #region properties 85 | 86 | public string Title 87 | { 88 | get 89 | { return label1.Text; } 90 | set 91 | { 92 | label1.Text = value; 93 | 94 | if (string.IsNullOrEmpty(value)) 95 | { 96 | panel1.Height = 0; 97 | panel2.Location = new Point(1, 1); 98 | } 99 | else 100 | { 101 | panel1.Height = 25; 102 | panel2.Location = new Point(1, 1 + 25 + 1); 103 | } 104 | } 105 | } 106 | 107 | #endregion 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /BitChatApp/UserControls/IChatMessageItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | 22 | namespace BitChatApp.UserControls 23 | { 24 | interface IChatMessageItem 25 | { 26 | MessageItem Message { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BitChatApp/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 52 | 59 | 60 | 61 | 62 | 63 | 64 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /BitChatApp/frmAbout.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System.Windows.Forms; 21 | 22 | namespace BitChatApp 23 | { 24 | public partial class frmAbout : Form 25 | { 26 | public frmAbout() 27 | { 28 | InitializeComponent(); 29 | 30 | labVersion.Text = "version " + Application.ProductVersion + " (alpha)"; 31 | } 32 | 33 | private void lnkTerms_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 34 | { 35 | System.Diagnostics.Process.Start(@"http://go.technitium.com/?id=3"); 36 | } 37 | 38 | private void lnkContactEmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 39 | { 40 | System.Diagnostics.Process.Start(@"mailto:support@bitchat.im"); 41 | } 42 | 43 | private void lnkWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 44 | { 45 | System.Diagnostics.Process.Start(@"https://bitchat.im/"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /BitChatApp/frmAddChat.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore.Network; 21 | using System; 22 | using System.Net.Mail; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp 26 | { 27 | public partial class frmAddChat : Form 28 | { 29 | #region variables 30 | 31 | BitChatNetworkType _type; 32 | 33 | #endregion 34 | 35 | #region constructor 36 | 37 | public frmAddChat(BitChatNetworkType type, string networkNameOrPeerEmailAddress) 38 | { 39 | InitializeComponent(); 40 | 41 | _type = type; 42 | 43 | if (networkNameOrPeerEmailAddress != null) 44 | txtNetworkNameOrPeerEmailAddress.Text = networkNameOrPeerEmailAddress; 45 | 46 | if (type == BitChatNetworkType.PrivateChat) 47 | { 48 | this.Text = "Add Private Chat"; 49 | 50 | label1.Text = "Peer's Email Address"; 51 | label3.Text = "(case insensitive, example: user@example.com)"; 52 | label4.Text = "Both peers must use same Shared Secret and enter each other's email address."; 53 | } 54 | else 55 | { 56 | this.Text = "Add Group Chat"; 57 | 58 | chkSendInvitation.Visible = false; 59 | txtInvitationMessage.Visible = false; 60 | label6.Visible = false; 61 | label7.Visible = false; 62 | 63 | this.Height = 220; 64 | } 65 | } 66 | 67 | #endregion 68 | 69 | #region form code 70 | 71 | private void txtSharedSecret_TextChanged(object sender, EventArgs e) 72 | { 73 | if (string.IsNullOrEmpty(txtSharedSecret.Text)) 74 | { 75 | chkSendInvitation.Enabled = true; 76 | txtInvitationMessage.Enabled = chkSendInvitation.Checked; 77 | } 78 | else 79 | { 80 | chkSendInvitation.Enabled = false; 81 | txtInvitationMessage.Enabled = false; 82 | } 83 | } 84 | 85 | private void chkLANChat_CheckedChanged(object sender, EventArgs e) 86 | { 87 | chkDhtOnlyTracking.Enabled = !chkLANChat.Checked; 88 | } 89 | 90 | private void chkSendInvitation_CheckedChanged(object sender, EventArgs e) 91 | { 92 | txtInvitationMessage.Enabled = chkSendInvitation.Checked; 93 | } 94 | 95 | private void btnOK_Click(object sender, EventArgs e) 96 | { 97 | txtNetworkNameOrPeerEmailAddress.Text = txtNetworkNameOrPeerEmailAddress.Text.Trim(); 98 | 99 | if (string.IsNullOrEmpty(txtNetworkNameOrPeerEmailAddress.Text)) 100 | { 101 | if (_type == BitChatNetworkType.PrivateChat) 102 | MessageBox.Show("Please enter an email address of your peer to chat with.", "Invalid Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error); 103 | else 104 | MessageBox.Show("Please enter a network name for the new chat.", "Missing Network Name", MessageBoxButtons.OK, MessageBoxIcon.Error); 105 | 106 | return; 107 | } 108 | 109 | if (_type == BitChatNetworkType.PrivateChat) 110 | { 111 | try 112 | { 113 | MailAddress x = new MailAddress(txtNetworkNameOrPeerEmailAddress.Text); 114 | } 115 | catch 116 | { 117 | MessageBox.Show("Please enter a valid email address of your peer to chat with.", "Invalid Email Address", MessageBoxButtons.OK, MessageBoxIcon.Error); 118 | return; 119 | } 120 | 121 | if (chkSendInvitation.Enabled && chkSendInvitation.Checked && string.IsNullOrEmpty(txtInvitationMessage.Text)) 122 | { 123 | MessageBox.Show("Please enter an invitation message for the new private chat.", "Missing Invitation Message", MessageBoxButtons.OK, MessageBoxIcon.Error); 124 | return; 125 | } 126 | } 127 | 128 | this.DialogResult = DialogResult.OK; 129 | this.Close(); 130 | } 131 | 132 | private void btnCancel_Click(object sender, EventArgs e) 133 | { 134 | this.Close(); 135 | } 136 | 137 | #endregion 138 | 139 | #region properties 140 | 141 | public string NetworkNameOrPeerEmailAddress 142 | { get { return txtNetworkNameOrPeerEmailAddress.Text; } } 143 | 144 | public string SharedSecret 145 | { get { return txtSharedSecret.Text; } } 146 | 147 | public bool OnlyLanChat 148 | { get { return chkLANChat.Checked; } } 149 | 150 | public bool DhtOnlyTracking 151 | { get { return chkDhtOnlyTracking.Enabled && chkDhtOnlyTracking.Checked; } } 152 | 153 | public string InvitationMessage 154 | { 155 | get 156 | { 157 | if (chkSendInvitation.Enabled && chkSendInvitation.Checked) 158 | return txtInvitationMessage.Text; 159 | else 160 | return null; 161 | } 162 | } 163 | 164 | #endregion 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /BitChatApp/frmAddTracker.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp 2 | { 3 | partial class frmAddTracker 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label3 = new System.Windows.Forms.Label(); 32 | this.txtTrackerURL = new System.Windows.Forms.TextBox(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.btnCancel = new System.Windows.Forms.Button(); 35 | this.btnOK = new System.Windows.Forms.Button(); 36 | this.SuspendLayout(); 37 | // 38 | // label3 39 | // 40 | this.label3.AutoSize = true; 41 | this.label3.Location = new System.Drawing.Point(104, 94); 42 | this.label3.Name = "label3"; 43 | this.label3.Size = new System.Drawing.Size(194, 13); 44 | this.label3.TabIndex = 9; 45 | this.label3.Text = "example: udp://tracker.publicbt.com:80"; 46 | // 47 | // txtTrackerURL 48 | // 49 | this.txtTrackerURL.Location = new System.Drawing.Point(107, 23); 50 | this.txtTrackerURL.Multiline = true; 51 | this.txtTrackerURL.Name = "txtTrackerURL"; 52 | this.txtTrackerURL.ScrollBars = System.Windows.Forms.ScrollBars.Both; 53 | this.txtTrackerURL.Size = new System.Drawing.Size(311, 68); 54 | this.txtTrackerURL.TabIndex = 8; 55 | // 56 | // label1 57 | // 58 | this.label1.AutoSize = true; 59 | this.label1.Location = new System.Drawing.Point(27, 26); 60 | this.label1.Name = "label1"; 61 | this.label1.Size = new System.Drawing.Size(74, 13); 62 | this.label1.TabIndex = 7; 63 | this.label1.Text = "Tracker URLs"; 64 | // 65 | // btnCancel 66 | // 67 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 68 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 69 | this.btnCancel.Location = new System.Drawing.Point(366, 118); 70 | this.btnCancel.Name = "btnCancel"; 71 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 72 | this.btnCancel.TabIndex = 11; 73 | this.btnCancel.Text = "Close"; 74 | this.btnCancel.UseVisualStyleBackColor = true; 75 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 76 | // 77 | // btnOK 78 | // 79 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 80 | this.btnOK.Location = new System.Drawing.Point(285, 118); 81 | this.btnOK.Name = "btnOK"; 82 | this.btnOK.Size = new System.Drawing.Size(75, 23); 83 | this.btnOK.TabIndex = 10; 84 | this.btnOK.Text = "Add"; 85 | this.btnOK.UseVisualStyleBackColor = true; 86 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click); 87 | // 88 | // frmAddTracker 89 | // 90 | this.AcceptButton = this.btnOK; 91 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 92 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 93 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))); 94 | this.CancelButton = this.btnCancel; 95 | this.ClientSize = new System.Drawing.Size(453, 148); 96 | this.Controls.Add(this.btnCancel); 97 | this.Controls.Add(this.btnOK); 98 | this.Controls.Add(this.label3); 99 | this.Controls.Add(this.txtTrackerURL); 100 | this.Controls.Add(this.label1); 101 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 102 | this.MaximizeBox = false; 103 | this.MinimizeBox = false; 104 | this.Name = "frmAddTracker"; 105 | this.ShowIcon = false; 106 | this.ShowInTaskbar = false; 107 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 108 | this.Text = "Add Tracker"; 109 | this.ResumeLayout(false); 110 | this.PerformLayout(); 111 | 112 | } 113 | 114 | #endregion 115 | 116 | private System.Windows.Forms.Label label3; 117 | public System.Windows.Forms.TextBox txtTrackerURL; 118 | private System.Windows.Forms.Label label1; 119 | private System.Windows.Forms.Button btnCancel; 120 | private System.Windows.Forms.Button btnOK; 121 | } 122 | } -------------------------------------------------------------------------------- /BitChatApp/frmAddTracker.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Drawing; 24 | using System.Linq; 25 | using System.Text; 26 | using System.Windows.Forms; 27 | 28 | namespace BitChatApp 29 | { 30 | public partial class frmAddTracker : Form 31 | { 32 | List _trackerUriList = new List(); 33 | 34 | public frmAddTracker(Uri[] trackers = null) 35 | { 36 | InitializeComponent(); 37 | 38 | if (trackers != null) 39 | { 40 | foreach (Uri tracker in trackers) 41 | { 42 | txtTrackerURL.Text += tracker.AbsoluteUri + "\r\n"; 43 | } 44 | } 45 | } 46 | 47 | private void btnCancel_Click(object sender, EventArgs e) 48 | { 49 | this.Close(); 50 | } 51 | 52 | private void btnOK_Click(object sender, EventArgs e) 53 | { 54 | try 55 | { 56 | string[] uriList = txtTrackerURL.Text.Split(new char[] { ' ', ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); 57 | 58 | foreach (string uri in uriList) 59 | _trackerUriList.Add(new Uri(uri)); 60 | } 61 | catch 62 | { 63 | MessageBox.Show("The tracker URL format is invalid. Please enter a valid tracker URL. Multiple URLs must be separated using space, comma or new line.", "Invalid Tracker URL", MessageBoxButtons.OK, MessageBoxIcon.Error); 64 | return; 65 | } 66 | 67 | this.DialogResult = System.Windows.Forms.DialogResult.OK; 68 | this.Close(); 69 | } 70 | 71 | public List TrackerUriList 72 | { get { return _trackerUriList; } } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /BitChatApp/frmImportPEM.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Security.Cryptography; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | using TechnitiumLibrary.Security.Cryptography; 11 | 12 | namespace BitChatApp 13 | { 14 | public partial class frmImportPEM : Form 15 | { 16 | #region variables 17 | 18 | RSAParameters _parameters; 19 | 20 | #endregion 21 | 22 | #region form code 23 | 24 | public frmImportPEM() 25 | { 26 | InitializeComponent(); 27 | } 28 | 29 | private void txtRSAKey_TextChanged(object sender, EventArgs e) 30 | { 31 | if (!txtRSAKey.Text.Contains("\r\n")) 32 | txtRSAKey.Text = txtRSAKey.Text.Replace("\n", "\r\n"); 33 | } 34 | 35 | private void btnOK_Click(object sender, EventArgs e) 36 | { 37 | try 38 | { 39 | using (MemoryStream mS = new MemoryStream(Encoding.UTF8.GetBytes(txtRSAKey.Text))) 40 | { 41 | _parameters = PEMFormat.ReadRSAPrivateKey(mS); 42 | } 43 | 44 | using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) 45 | { 46 | rsa.ImportParameters(_parameters); 47 | 48 | if (rsa.KeySize < 4096) 49 | { 50 | MessageBox.Show("The RSA private key must be at least 4096-bit. The current key is " + rsa.KeySize + "-bit.", "Short RSA Private Key", MessageBoxButtons.OK, MessageBoxIcon.Error); 51 | return; 52 | } 53 | } 54 | 55 | this.DialogResult = System.Windows.Forms.DialogResult.OK; 56 | this.Close(); 57 | } 58 | catch 59 | { 60 | MessageBox.Show("Error in reading PEM format. Please make sure you have pasted the RSA private key in a proper PEM format.", "Invalid PEM Format", MessageBoxButtons.OK, MessageBoxIcon.Error); 61 | } 62 | } 63 | 64 | private void btnCancel_Click(object sender, EventArgs e) 65 | { 66 | this.Close(); 67 | } 68 | 69 | #endregion 70 | 71 | #region properties 72 | 73 | public RSAParameters Parameters 74 | { get { return _parameters; } } 75 | 76 | #endregion 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /BitChatApp/frmMessageInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatApp.UserControls; 21 | using BitChatCore; 22 | using System; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp 26 | { 27 | public partial class frmMessageInfo : Form 28 | { 29 | ChatMessageTextItem chatMessageDisplay; 30 | MessageItem _message; 31 | 32 | public frmMessageInfo(BitChat.Peer selfPeer, MessageItem message) 33 | { 34 | _message = message; 35 | 36 | this.SuspendLayout(); 37 | 38 | InitializeComponent(); 39 | 40 | chatMessageDisplay = new ChatMessageTextItem(selfPeer, _message); 41 | chatMessageDisplay.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; 42 | chatMessageDisplay.Width = chatMessagePanel.Width - 30; 43 | chatMessageDisplay.ContextMenuStrip = null; 44 | 45 | if (chatMessageDisplay.Height > 150) 46 | { 47 | chatMessagePanel.Height = 140; 48 | } 49 | else 50 | { 51 | chatMessagePanel.Height = chatMessageDisplay.Height + 10; 52 | 53 | int heightDiff = 150 - chatMessagePanel.Height; 54 | 55 | this.Height -= heightDiff; 56 | listView1.Top -= heightDiff; 57 | btnClose.Top -= heightDiff; 58 | } 59 | 60 | chatMessagePanel.Controls.Add(chatMessageDisplay); 61 | 62 | this.ResumeLayout(); 63 | } 64 | 65 | private void frmMessageInfo_Load(object sender, EventArgs e) 66 | { 67 | foreach (MessageRecipient rcpt in _message.Recipients) 68 | { 69 | ListViewItem item = listView1.Items.Add(rcpt.Name); 70 | 71 | switch (rcpt.Status) 72 | { 73 | case MessageRecipientStatus.Delivered: 74 | item.SubItems.Add("Delivered on " + rcpt.DeliveredOn.ToLocalTime().ToString()); 75 | break; 76 | 77 | case MessageRecipientStatus.Undelivered: 78 | item.SubItems.Add("Undelivered"); 79 | break; 80 | } 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /BitChatApp/frmPassword.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using System; 22 | using System.IO; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp 26 | { 27 | public partial class frmPassword : Form 28 | { 29 | #region variables 30 | 31 | string _profileFilePath; 32 | bool _isPortableApp; 33 | string _profileFolder; 34 | 35 | BitChatProfile _profile; 36 | 37 | #endregion 38 | 39 | #region constructor 40 | 41 | public frmPassword(string profileFilePath, bool isPortableApp, string profileFolder) 42 | { 43 | InitializeComponent(); 44 | 45 | _profileFilePath = profileFilePath; 46 | _isPortableApp = isPortableApp; 47 | _profileFolder = profileFolder; 48 | 49 | labProfileName.Text = Path.GetFileNameWithoutExtension(_profileFilePath); 50 | } 51 | 52 | #endregion 53 | 54 | #region private 55 | 56 | private void btnOK_Click(object sender, EventArgs e) 57 | { 58 | try 59 | { 60 | using (FileStream fS = new FileStream(_profileFilePath, FileMode.Open, FileAccess.Read)) 61 | { 62 | _profile = new BitChatProfile(fS, txtPassword.Text, _isPortableApp, _profileFolder); 63 | } 64 | 65 | DialogResult = System.Windows.Forms.DialogResult.OK; 66 | this.Close(); 67 | } 68 | catch 69 | { 70 | try 71 | { 72 | using (FileStream fS = new FileStream(_profileFilePath + ".bak", FileMode.Open, FileAccess.Read)) 73 | { 74 | _profile = new BitChatProfile(fS, txtPassword.Text, _isPortableApp, _profileFolder); 75 | } 76 | 77 | DialogResult = System.Windows.Forms.DialogResult.OK; 78 | this.Close(); 79 | } 80 | catch 81 | { 82 | MessageBox.Show("Invalid password or file data tampered. Please try again.", "Invalid Password!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 83 | 84 | txtPassword.Text = ""; 85 | txtPassword.Focus(); 86 | } 87 | } 88 | } 89 | 90 | private void btnBack_Click(object sender, EventArgs e) 91 | { 92 | this.Close(); 93 | } 94 | 95 | private void lnkForgotPassword_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 96 | { 97 | if (MessageBox.Show("Since the profile password is used to encrypt the profile data, there is no method to recover the encryption password or the profile data.\r\n\r\nTo access Bit Chat, you will need to register a new profile and you can use the same email address for registration. You will lose all your settings and you will have to join all your chats again.\r\n\r\nDo you want to register a new profile now?", "Register New Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) 98 | { 99 | this.DialogResult = System.Windows.Forms.DialogResult.Yes; 100 | this.Close(); 101 | } 102 | } 103 | 104 | #endregion 105 | 106 | #region properties 107 | 108 | public BitChatProfile Profile 109 | { get { return _profile; } } 110 | 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /BitChatApp/frmShareFileSelection.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp 2 | { 3 | partial class frmShareFileSelection 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmShareFileSelection)); 32 | this.checkedListBox1 = new System.Windows.Forms.CheckedListBox(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.btnOK = new System.Windows.Forms.Button(); 35 | this.btnCancel = new System.Windows.Forms.Button(); 36 | this.SuspendLayout(); 37 | // 38 | // checkedListBox1 39 | // 40 | this.checkedListBox1.CheckOnClick = true; 41 | this.checkedListBox1.FormattingEnabled = true; 42 | this.checkedListBox1.IntegralHeight = false; 43 | this.checkedListBox1.Location = new System.Drawing.Point(12, 31); 44 | this.checkedListBox1.Name = "checkedListBox1"; 45 | this.checkedListBox1.Size = new System.Drawing.Size(260, 243); 46 | this.checkedListBox1.Sorted = true; 47 | this.checkedListBox1.TabIndex = 0; 48 | // 49 | // label1 50 | // 51 | this.label1.Location = new System.Drawing.Point(9, 11); 52 | this.label1.Name = "label1"; 53 | this.label1.Size = new System.Drawing.Size(260, 15); 54 | this.label1.TabIndex = 1; 55 | this.label1.Text = "Select the chats from below list to share the file:"; 56 | // 57 | // btnOK 58 | // 59 | this.btnOK.Location = new System.Drawing.Point(116, 280); 60 | this.btnOK.Name = "btnOK"; 61 | this.btnOK.Size = new System.Drawing.Size(75, 23); 62 | this.btnOK.TabIndex = 2; 63 | this.btnOK.Text = "OK"; 64 | this.btnOK.UseVisualStyleBackColor = true; 65 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click); 66 | // 67 | // btnCancel 68 | // 69 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 70 | this.btnCancel.Location = new System.Drawing.Point(197, 280); 71 | this.btnCancel.Name = "btnCancel"; 72 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 73 | this.btnCancel.TabIndex = 3; 74 | this.btnCancel.Text = "Cancel"; 75 | this.btnCancel.UseVisualStyleBackColor = true; 76 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 77 | // 78 | // frmShareFileSelection 79 | // 80 | this.AcceptButton = this.btnOK; 81 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 82 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 83 | this.CancelButton = this.btnCancel; 84 | this.ClientSize = new System.Drawing.Size(284, 311); 85 | this.Controls.Add(this.btnCancel); 86 | this.Controls.Add(this.btnOK); 87 | this.Controls.Add(this.label1); 88 | this.Controls.Add(this.checkedListBox1); 89 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 90 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 91 | this.MaximizeBox = false; 92 | this.MinimizeBox = false; 93 | this.Name = "frmShareFileSelection"; 94 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 95 | this.Text = "Share File"; 96 | this.ResumeLayout(false); 97 | 98 | } 99 | 100 | #endregion 101 | 102 | private System.Windows.Forms.CheckedListBox checkedListBox1; 103 | private System.Windows.Forms.Label label1; 104 | private System.Windows.Forms.Button btnOK; 105 | private System.Windows.Forms.Button btnCancel; 106 | } 107 | } -------------------------------------------------------------------------------- /BitChatApp/frmShareFileSelection.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using BitChatCore.FileSharing; 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Windows.Forms; 25 | 26 | namespace BitChatApp 27 | { 28 | public partial class frmShareFileSelection : Form 29 | { 30 | List _selectedChats; 31 | 32 | public frmShareFileSelection(BitChatNode node, SharedFile sharedFile) 33 | { 34 | InitializeComponent(); 35 | 36 | BitChat[] sharedChats = sharedFile.GetChatList(); 37 | 38 | foreach (BitChat chat in node.GetBitChatList()) 39 | { 40 | bool found = false; 41 | 42 | foreach (BitChat sharedChat in sharedChats) 43 | { 44 | if (sharedChat == chat) 45 | { 46 | found = true; 47 | break; 48 | } 49 | } 50 | 51 | if (!found) 52 | checkedListBox1.Items.Add(chat); 53 | } 54 | } 55 | 56 | private void btnOK_Click(object sender, EventArgs e) 57 | { 58 | _selectedChats = new List(); 59 | 60 | foreach (BitChat item in checkedListBox1.CheckedItems) 61 | _selectedChats.Add(item); 62 | 63 | DialogResult = DialogResult.OK; 64 | this.Close(); 65 | } 66 | 67 | private void btnCancel_Click(object sender, EventArgs e) 68 | { 69 | DialogResult = DialogResult.Cancel; 70 | this.Close(); 71 | } 72 | 73 | public List SelectedChats 74 | { get { return _selectedChats; } } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /BitChatApp/frmWelcome.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using System; 22 | using System.Windows.Forms; 23 | 24 | namespace BitChatApp 25 | { 26 | public partial class frmWelcome : Form 27 | { 28 | #region variables 29 | 30 | bool _isPortableApp; 31 | string _profileFolder; 32 | 33 | BitChatProfile _profile; 34 | string _profileFilePath; 35 | 36 | #endregion 37 | 38 | #region constructors 39 | 40 | public frmWelcome(bool isPortableApp, string profileFolder) 41 | { 42 | InitializeComponent(); 43 | 44 | _isPortableApp = isPortableApp; 45 | _profileFolder = profileFolder; 46 | } 47 | 48 | #endregion 49 | 50 | #region private 51 | 52 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 53 | { 54 | System.Diagnostics.Process.Start("https://bitchat.im"); 55 | } 56 | 57 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 58 | { 59 | System.Diagnostics.Process.Start("http://blog.technitium.com/2015/11/how-to-register-profile-get-started.html"); 60 | } 61 | 62 | private void frmRegisterNow_Click(object sender, EventArgs e) 63 | { 64 | this.Hide(); 65 | 66 | using (frmRegister frm = new frmRegister(_isPortableApp, _profileFolder)) 67 | { 68 | DialogResult result = frm.ShowDialog(this); 69 | 70 | switch (result) 71 | { 72 | case System.Windows.Forms.DialogResult.OK: 73 | _profile = frm.Profile; 74 | _profileFilePath = frm.ProfileFilePath; 75 | 76 | this.DialogResult = System.Windows.Forms.DialogResult.OK; 77 | this.Close(); 78 | break; 79 | 80 | case System.Windows.Forms.DialogResult.Ignore: 81 | this.Show(); 82 | break; 83 | 84 | default: 85 | this.DialogResult = System.Windows.Forms.DialogResult.Cancel; 86 | this.Close(); 87 | break; 88 | } 89 | } 90 | } 91 | 92 | private void btnAlreadyRegistered_Click(object sender, EventArgs e) 93 | { 94 | this.DialogResult = System.Windows.Forms.DialogResult.Ignore; 95 | this.Close(); 96 | } 97 | 98 | #endregion 99 | 100 | #region properties 101 | 102 | public BitChatProfile Profile 103 | { get { return _profile; } } 104 | 105 | public string ProfileFilePath 106 | { get { return _profileFilePath; } } 107 | 108 | #endregion 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /BitChatApp/logo2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatApp/logo2.ico -------------------------------------------------------------------------------- /BitChatAppMono/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("Bit Chat")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Technitium")] 12 | [assembly: AssemblyProduct("Bit Chat")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 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("369b279d-562a-4555-bef6-c228758f4aca")] 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("4.6.3.0")] 36 | [assembly: AssemblyFileVersion("4.6.3.0")] 37 | -------------------------------------------------------------------------------- /BitChatAppMono/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 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 BitChatApp.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.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 | -------------------------------------------------------------------------------- /BitChatAppMono/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /BitChatAppMono/Resources/Attachment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/Attachment.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/FullNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/FullNetwork.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/MessageNotification.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/MessageNotification.wav -------------------------------------------------------------------------------- /BitChatAppMono/Resources/NoNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/NoNetwork.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/PartialNetwork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/PartialNetwork.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/change-photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/change-photo.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/double-ticks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/double-ticks.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/message-failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/message-failed.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/point-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/point-left.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/point-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/point-right.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/send message.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/send message.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/single-tick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/single-tick.png -------------------------------------------------------------------------------- /BitChatAppMono/Resources/waiting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/Resources/waiting.png -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/ChatMessageInfoItem.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class ChatMessageInfoItem 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); 34 | this.copyInfoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 35 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 36 | this.contextMenuStrip1.SuspendLayout(); 37 | this.SuspendLayout(); 38 | // 39 | // label1 40 | // 41 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 42 | | System.Windows.Forms.AnchorStyles.Right))); 43 | this.label1.AutoEllipsis = true; 44 | this.label1.AutoSize = true; 45 | this.label1.BackColor = System.Drawing.Color.Azure; 46 | this.label1.ContextMenuStrip = this.contextMenuStrip1; 47 | this.label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 48 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64))))); 49 | this.label1.Location = new System.Drawing.Point(0, 6); 50 | this.label1.Name = "label1"; 51 | this.label1.Padding = new System.Windows.Forms.Padding(3); 52 | this.label1.Size = new System.Drawing.Size(116, 20); 53 | this.label1.TabIndex = 0; 54 | this.label1.Text = "Sample Info Message"; 55 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; 56 | // 57 | // contextMenuStrip1 58 | // 59 | this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 60 | this.copyInfoToolStripMenuItem}); 61 | this.contextMenuStrip1.Name = "contextMenuStrip1"; 62 | this.contextMenuStrip1.Size = new System.Drawing.Size(127, 26); 63 | // 64 | // copyInfoToolStripMenuItem 65 | // 66 | this.copyInfoToolStripMenuItem.Name = "copyInfoToolStripMenuItem"; 67 | this.copyInfoToolStripMenuItem.Size = new System.Drawing.Size(126, 22); 68 | this.copyInfoToolStripMenuItem.Text = "Copy Info"; 69 | this.copyInfoToolStripMenuItem.Click += new System.EventHandler(this.copyInfoToolStripMenuItem_Click); 70 | // 71 | // ChatMessageInfoItem 72 | // 73 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 74 | this.BackColor = System.Drawing.Color.Transparent; 75 | this.ContextMenuStrip = this.contextMenuStrip1; 76 | this.Controls.Add(this.label1); 77 | this.Name = "ChatMessageInfoItem"; 78 | this.Size = new System.Drawing.Size(600, 32); 79 | this.contextMenuStrip1.ResumeLayout(false); 80 | this.ResumeLayout(false); 81 | this.PerformLayout(); 82 | 83 | } 84 | 85 | #endregion 86 | 87 | private System.Windows.Forms.Label label1; 88 | private System.Windows.Forms.ContextMenuStrip contextMenuStrip1; 89 | private System.Windows.Forms.ToolStripMenuItem copyInfoToolStripMenuItem; 90 | private System.Windows.Forms.ToolTip toolTip1; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/ChatMessageInfoItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using System; 22 | using System.Drawing; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp.UserControls 26 | { 27 | public partial class ChatMessageInfoItem : CustomListViewItem, IChatMessageItem 28 | { 29 | #region variables 30 | 31 | MessageItem _message; 32 | 33 | #endregion 34 | 35 | #region constructor 36 | 37 | public ChatMessageInfoItem(MessageItem message) 38 | { 39 | InitializeComponent(); 40 | 41 | _message = message; 42 | 43 | if (string.IsNullOrEmpty(_message.Message)) 44 | { 45 | label1.Text = _message.MessageDate.ToLocalTime().ToString("dddd, MMMM d, yyyy"); 46 | } 47 | else 48 | { 49 | label1.Text = _message.Message; 50 | toolTip1.SetToolTip(label1, _message.MessageDate.ToLocalTime().ToString()); 51 | } 52 | 53 | OnResize(EventArgs.Empty); 54 | } 55 | 56 | #endregion 57 | 58 | #region form code 59 | 60 | protected override void OnResize(EventArgs e) 61 | { 62 | base.OnResize(e); 63 | 64 | if (label1 != null) 65 | { 66 | this.SuspendLayout(); 67 | 68 | if (label1.Width > (this.Width - 4)) 69 | { 70 | label1.AutoSize = false; 71 | label1.Left = 2; 72 | label1.Width = this.Width - 4; 73 | 74 | Size msgSize = TextRenderer.MeasureText(label1.Text, label1.Font, new Size(label1.Width - 3 - 3, int.MaxValue), TextFormatFlags.WordBreak | TextFormatFlags.TextBoxControl); 75 | 76 | label1.Height = msgSize.Height + 3 + 3; 77 | this.Height = label1.Height + 6 + 6; 78 | } 79 | else 80 | { 81 | label1.AutoSize = true; 82 | label1.Left = (this.Width - label1.Width) / 2; 83 | } 84 | 85 | this.ResumeLayout(); 86 | } 87 | 88 | this.Refresh(); 89 | } 90 | 91 | private void copyInfoToolStripMenuItem_Click(object sender, EventArgs e) 92 | { 93 | try 94 | { 95 | if (string.IsNullOrEmpty(_message.Message)) 96 | Clipboard.SetText(label1.Text); 97 | else 98 | Clipboard.SetText("[" + _message.MessageDate.ToString("d MMM, yyyy HH:mm:ss") + "] " + label1.Text); 99 | } 100 | catch 101 | { } 102 | } 103 | 104 | #endregion 105 | 106 | #region properties 107 | 108 | public MessageItem Message 109 | { get { return _message; } } 110 | 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomButton.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.Drawing; 23 | using System.Text; 24 | using System.Windows.Forms; 25 | 26 | namespace BitChatApp.UserControls 27 | { 28 | public class CustomButton : PictureBox 29 | { 30 | #region variables 31 | 32 | Image _image; 33 | 34 | #endregion 35 | 36 | #region constructor 37 | 38 | public CustomButton() 39 | : base() 40 | { 41 | this.SizeMode = PictureBoxSizeMode.AutoSize; 42 | } 43 | 44 | #endregion 45 | 46 | #region protected 47 | 48 | protected override void OnCreateControl() 49 | { 50 | base.OnCreateControl(); 51 | 52 | _image = this.Image; 53 | } 54 | 55 | protected override void OnMouseEnter(EventArgs e) 56 | { 57 | base.OnMouseEnter(e); 58 | 59 | base.Image = this.ImageHover; 60 | } 61 | 62 | protected override void OnMouseLeave(EventArgs e) 63 | { 64 | base.OnMouseLeave(e); 65 | 66 | this.Image = _image; 67 | } 68 | 69 | protected override void OnMouseDown(MouseEventArgs e) 70 | { 71 | base.OnMouseDown(e); 72 | 73 | this.Image = this.ImageMouseDown; 74 | } 75 | 76 | protected override void OnMouseUp(MouseEventArgs e) 77 | { 78 | base.OnMouseUp(e); 79 | 80 | this.Image = _image; 81 | } 82 | 83 | #endregion 84 | 85 | #region properties 86 | 87 | public Image ImageHover 88 | { get; set; } 89 | 90 | public Image ImageMouseDown 91 | { get; set; } 92 | 93 | #endregion 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomListView.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomListView 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // CustomListView 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.AutoScroll = true; 38 | this.BackColor = System.Drawing.Color.White; 39 | this.Name = "CustomListView"; 40 | this.Size = new System.Drawing.Size(262, 257); 41 | this.ResumeLayout(false); 42 | 43 | } 44 | 45 | #endregion 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomListViewItem.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomListViewItem 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // CustomListViewItem 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "CustomListViewItem"; 38 | this.Size = new System.Drawing.Size(167, 77); 39 | this.Load += new System.EventHandler(this.CustomListViewItem_Load); 40 | this.ResumeLayout(false); 41 | 42 | } 43 | 44 | #endregion 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomListViewItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Drawing; 22 | using System.Windows.Forms; 23 | 24 | namespace BitChatApp.UserControls 25 | { 26 | public partial class CustomListViewItem : UserControl 27 | { 28 | #region event 29 | 30 | public event EventHandler SortList; 31 | 32 | #endregion 33 | 34 | #region variables 35 | 36 | const int BORDER_SIZE = 1; 37 | 38 | bool _selected = false; 39 | 40 | #endregion 41 | 42 | #region constructor 43 | 44 | public CustomListViewItem() 45 | { 46 | InitializeComponent(); 47 | } 48 | 49 | #endregion 50 | 51 | #region private 52 | 53 | private void CustomListViewItem_Load(object sender, EventArgs e) 54 | { 55 | foreach (Control ctrl in Controls) 56 | { 57 | ctrl.Click += ctrl_Click; 58 | ctrl.DoubleClick += ctrl_DoubleClick; 59 | ctrl.MouseUp += ctrl_MouseUp; 60 | ctrl.MouseLeave += ctrl_MouseLeave; 61 | ctrl.MouseEnter += ctrl_MouseEnter; 62 | ctrl.KeyDown += ctrl_KeyDown; 63 | ctrl.KeyUp += ctrl_KeyUp; 64 | ctrl.KeyPress += ctrl_KeyPress; 65 | } 66 | } 67 | 68 | private void ctrl_Click(object sender, EventArgs e) 69 | { 70 | OnClick(EventArgs.Empty); 71 | } 72 | 73 | private void ctrl_DoubleClick(object sender, EventArgs e) 74 | { 75 | OnDoubleClick(EventArgs.Empty); 76 | } 77 | 78 | private void ctrl_MouseUp(object sender, MouseEventArgs e) 79 | { 80 | if (sender != this) 81 | { 82 | Control obj = sender as Control; 83 | e = new MouseEventArgs(e.Button, e.Clicks, obj.Location.X + e.X, obj.Location.Y + e.Y, e.Delta); 84 | } 85 | 86 | OnMouseUp(e); 87 | } 88 | 89 | private void ctrl_MouseEnter(object sender, EventArgs e) 90 | { 91 | OnMouseEnter(e); 92 | } 93 | 94 | private void ctrl_MouseLeave(object sender, EventArgs e) 95 | { 96 | OnMouseLeave(e); 97 | } 98 | 99 | private void ctrl_KeyPress(object sender, KeyPressEventArgs e) 100 | { 101 | OnKeyPress(e); 102 | } 103 | 104 | private void ctrl_KeyUp(object sender, KeyEventArgs e) 105 | { 106 | OnKeyUp(e); 107 | } 108 | 109 | private void ctrl_KeyDown(object sender, KeyEventArgs e) 110 | { 111 | OnKeyDown(e); 112 | } 113 | 114 | #endregion 115 | 116 | #region protected 117 | 118 | protected virtual void OnSelected() 119 | { } 120 | 121 | protected virtual void OnMouseOver(bool hovering) 122 | { } 123 | 124 | protected override void OnPaint(PaintEventArgs e) 125 | { 126 | base.OnPaint(e); 127 | 128 | ControlPaint.DrawBorder(e.Graphics, ClientRectangle, 129 | SeparatorColor, 0, ButtonBorderStyle.Solid, 130 | SeparatorColor, 0, ButtonBorderStyle.Solid, 131 | SeparatorColor, 0, ButtonBorderStyle.Solid, 132 | SeparatorColor, BORDER_SIZE, ButtonBorderStyle.Solid); 133 | } 134 | 135 | protected override void OnMouseEnter(EventArgs e) 136 | { 137 | if (this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) 138 | { 139 | base.OnMouseEnter(e); 140 | OnMouseOver(true); 141 | } 142 | } 143 | 144 | protected override void OnMouseLeave(EventArgs e) 145 | { 146 | if (!this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition))) 147 | { 148 | base.OnMouseLeave(e); 149 | OnMouseOver(false); 150 | } 151 | } 152 | 153 | protected void SortListView() 154 | { 155 | if (SortList != null) 156 | SortList(this, EventArgs.Empty); 157 | } 158 | 159 | #endregion 160 | 161 | #region properties 162 | 163 | public Color SeparatorColor 164 | { set; get; } 165 | 166 | public bool Selected 167 | { 168 | get { return _selected; } 169 | set 170 | { 171 | if (_selected != value) 172 | { 173 | _selected = value; 174 | 175 | this.SuspendLayout(); 176 | 177 | OnSelected(); 178 | 179 | this.ResumeLayout(); 180 | } 181 | } 182 | } 183 | 184 | #endregion 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomListViewPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomListViewPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.customListView1 = new BitChatApp.UserControls.CustomListView(); 32 | this.panel2.SuspendLayout(); 33 | this.SuspendLayout(); 34 | // 35 | // panel2 36 | // 37 | this.panel2.Controls.Add(this.customListView1); 38 | // 39 | // customListView1 40 | // 41 | this.customListView1.AutoScroll = true; 42 | this.customListView1.AutoScrollToBottom = false; 43 | this.customListView1.BackColor = System.Drawing.Color.White; 44 | this.customListView1.BorderColor = System.Drawing.Color.Empty; 45 | this.customListView1.Dock = System.Windows.Forms.DockStyle.Fill; 46 | this.customListView1.Location = new System.Drawing.Point(0, 0); 47 | this.customListView1.Name = "customListView1"; 48 | this.customListView1.SeparatorColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(223))))); 49 | this.customListView1.Size = new System.Drawing.Size(297, 121); 50 | this.customListView1.TabIndex = 4; 51 | this.customListView1.ItemClick += new System.EventHandler(this.customListView1_ItemClick); 52 | this.customListView1.ItemDoubleClick += new System.EventHandler(this.customListView1_ItemDoubleClick); 53 | this.customListView1.ItemMouseUp += new System.Windows.Forms.MouseEventHandler(this.customListView1_ItemMouseUp); 54 | this.customListView1.ItemKeyDown += new System.Windows.Forms.KeyEventHandler(this.customListView1_ItemKeyDown); 55 | this.customListView1.ItemKeyUp += new System.Windows.Forms.KeyEventHandler(this.customListView1_ItemKeyUp); 56 | this.customListView1.ItemKeyPress += new System.Windows.Forms.KeyPressEventHandler(this.customListView1_ItemKeyPress); 57 | // 58 | // CustomListView2 59 | // 60 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 61 | this.Name = "CustomListView2"; 62 | this.panel2.ResumeLayout(false); 63 | this.ResumeLayout(false); 64 | 65 | } 66 | 67 | #endregion 68 | 69 | private CustomListView customListView1; 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomListViewPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Windows.Forms; 22 | 23 | namespace BitChatApp.UserControls 24 | { 25 | public partial class CustomListViewPanel : CustomPanel 26 | { 27 | #region events 28 | 29 | public event EventHandler ItemClick; 30 | public event EventHandler ItemDoubleClick; 31 | public event MouseEventHandler ItemMouseUp; 32 | public event KeyEventHandler ItemKeyDown; 33 | public event KeyEventHandler ItemKeyUp; 34 | public event KeyPressEventHandler ItemKeyPress; 35 | 36 | #endregion 37 | 38 | #region constructor 39 | 40 | public CustomListViewPanel() 41 | { 42 | InitializeComponent(); 43 | } 44 | 45 | #endregion 46 | 47 | #region public 48 | 49 | public CustomListViewItem AddItem(CustomListViewItem item) 50 | { 51 | return customListView1.AddItem(item); 52 | } 53 | 54 | public bool RemoveItem(CustomListViewItem item) 55 | { 56 | return customListView1.RemoveItem(item); 57 | } 58 | 59 | public void RemoveAllItems() 60 | { 61 | customListView1.RemoveAllItems(); 62 | } 63 | 64 | #endregion 65 | 66 | #region private 67 | 68 | private void customListView1_ItemClick(object sender, EventArgs e) 69 | { 70 | if (ItemClick != null) 71 | ItemClick(sender, e); 72 | } 73 | 74 | private void customListView1_ItemDoubleClick(object sender, EventArgs e) 75 | { 76 | if (ItemDoubleClick != null) 77 | ItemDoubleClick(sender, e); 78 | } 79 | 80 | private void customListView1_ItemKeyDown(object sender, KeyEventArgs e) 81 | { 82 | if (ItemKeyDown != null) 83 | ItemKeyDown(sender, e); 84 | } 85 | 86 | private void customListView1_ItemKeyPress(object sender, KeyPressEventArgs e) 87 | { 88 | if (ItemKeyPress != null) 89 | ItemKeyPress(sender, e); 90 | } 91 | 92 | private void customListView1_ItemKeyUp(object sender, KeyEventArgs e) 93 | { 94 | if (ItemKeyUp != null) 95 | ItemKeyUp(sender, e); 96 | } 97 | 98 | private void customListView1_ItemMouseUp(object sender, MouseEventArgs e) 99 | { 100 | if (ItemMouseUp != null) 101 | ItemMouseUp(sender, e); 102 | } 103 | 104 | #endregion 105 | 106 | #region properties 107 | 108 | public CustomListViewItem SelectedItem 109 | { get { return customListView1.SelectedItem; } } 110 | 111 | public int SeperatorSize 112 | { 113 | get { return customListView1.Padding.Top; } 114 | set { customListView1.Padding = new Padding(value, value, value, 0); } 115 | } 116 | 117 | public ControlCollection Items 118 | { get { return customListView1.Controls; } } 119 | 120 | public bool SortItems 121 | { 122 | get { return customListView1.SortItems; } 123 | set { customListView1.SortItems = value; } 124 | } 125 | 126 | #endregion 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomPanel.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp.UserControls 2 | { 3 | partial class CustomPanel 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.panel1 = new System.Windows.Forms.Panel(); 32 | this.label1 = new System.Windows.Forms.Label(); 33 | this.panel2 = new System.Windows.Forms.Panel(); 34 | this.panel1.SuspendLayout(); 35 | this.SuspendLayout(); 36 | // 37 | // panel1 38 | // 39 | this.panel1.BackColor = System.Drawing.Color.WhiteSmoke; 40 | this.panel1.Controls.Add(this.label1); 41 | this.panel1.Dock = System.Windows.Forms.DockStyle.Top; 42 | this.panel1.Location = new System.Drawing.Point(1, 1); 43 | this.panel1.Name = "panel1"; 44 | this.panel1.Size = new System.Drawing.Size(297, 25); 45 | this.panel1.TabIndex = 2; 46 | // 47 | // label1 48 | // 49 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 50 | | System.Windows.Forms.AnchorStyles.Right))); 51 | this.label1.AutoEllipsis = true; 52 | this.label1.Font = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); 53 | this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(67)))), ((int)(((byte)(74)))), ((int)(((byte)(84))))); 54 | this.label1.Location = new System.Drawing.Point(5, 2); 55 | this.label1.Name = "label1"; 56 | this.label1.Size = new System.Drawing.Size(287, 21); 57 | this.label1.TabIndex = 2; 58 | this.label1.Text = "Title"; 59 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; 60 | // 61 | // panel2 62 | // 63 | this.panel2.BackColor = System.Drawing.Color.White; 64 | this.panel2.Location = new System.Drawing.Point(1, 27); 65 | this.panel2.Name = "panel2"; 66 | this.panel2.Size = new System.Drawing.Size(297, 121); 67 | this.panel2.TabIndex = 3; 68 | // 69 | // CustomPanel 70 | // 71 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 72 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 73 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(223))))); 74 | this.Controls.Add(this.panel2); 75 | this.Controls.Add(this.panel1); 76 | this.Name = "CustomPanel"; 77 | this.Padding = new System.Windows.Forms.Padding(1, 1, 2, 2); 78 | this.Size = new System.Drawing.Size(300, 150); 79 | this.panel1.ResumeLayout(false); 80 | this.ResumeLayout(false); 81 | 82 | } 83 | 84 | #endregion 85 | 86 | private System.Windows.Forms.Panel panel1; 87 | private System.Windows.Forms.Label label1; 88 | protected System.Windows.Forms.Panel panel2; 89 | 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/CustomPanel.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Drawing; 24 | using System.Text; 25 | using System.Windows.Forms; 26 | using System.ComponentModel.Design; 27 | 28 | namespace BitChatApp.UserControls 29 | { 30 | [Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))] 31 | public partial class CustomPanel : UserControl 32 | { 33 | #region variables 34 | 35 | const int BORDER_SIZE = 1; 36 | 37 | Color BorderColor = Color.FromArgb(224, 224, 223); 38 | Color BorderColorShadow = Color.FromArgb(199, 199, 198); 39 | 40 | #endregion 41 | 42 | #region constructor 43 | 44 | public CustomPanel() 45 | { 46 | InitializeComponent(); 47 | } 48 | 49 | #endregion 50 | 51 | #region private 52 | 53 | protected override void OnPaint(PaintEventArgs e) 54 | { 55 | base.OnPaint(e); 56 | 57 | ControlPaint.DrawBorder(e.Graphics, ClientRectangle, 58 | BorderColor, 0, ButtonBorderStyle.Solid, 59 | BorderColor, 0, ButtonBorderStyle.Solid, 60 | BorderColorShadow, BORDER_SIZE * 2, ButtonBorderStyle.Solid, 61 | BorderColorShadow, BORDER_SIZE * 2, ButtonBorderStyle.Solid); 62 | 63 | ControlPaint.DrawBorder(e.Graphics, ClientRectangle, 64 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid, 65 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid, 66 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid, 67 | BorderColor, BORDER_SIZE, ButtonBorderStyle.Solid); 68 | } 69 | 70 | protected override void OnResize(EventArgs e) 71 | { 72 | if (panel1.Height == 0) 73 | panel2.Size = new Size(this.Width - 1 - 2, this.Height - 1 - 2); 74 | else 75 | panel2.Size = new Size(this.Width - 1 - 2, this.Height - panel1.Height - 1 - 1 - 2); 76 | 77 | base.OnResize(e); 78 | 79 | this.Refresh(); 80 | } 81 | 82 | #endregion 83 | 84 | #region properties 85 | 86 | public string Title 87 | { 88 | get 89 | { return label1.Text; } 90 | set 91 | { 92 | label1.Text = value; 93 | 94 | if (string.IsNullOrEmpty(value)) 95 | { 96 | panel1.Height = 0; 97 | panel2.Location = new Point(1, 1); 98 | } 99 | else 100 | { 101 | panel1.Height = 25; 102 | panel2.Location = new Point(1, 1 + 25 + 1); 103 | } 104 | } 105 | } 106 | 107 | #endregion 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /BitChatAppMono/UserControls/IChatMessageItem.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | 22 | namespace BitChatApp.UserControls 23 | { 24 | interface IChatMessageItem 25 | { 26 | MessageItem Message { get; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BitChatAppMono/frmAbout.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System.Windows.Forms; 21 | 22 | namespace BitChatApp 23 | { 24 | public partial class frmAbout : Form 25 | { 26 | public frmAbout() 27 | { 28 | InitializeComponent(); 29 | 30 | labVersion.Text = "version " + Application.ProductVersion + " (alpha)"; 31 | } 32 | 33 | private void lnkTerms_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 34 | { 35 | System.Diagnostics.Process.Start(@"http://go.technitium.com/?id=3"); 36 | } 37 | 38 | private void lnkContactEmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 39 | { 40 | System.Diagnostics.Process.Start(@"mailto:support@bitchat.im"); 41 | } 42 | 43 | private void lnkWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 44 | { 45 | System.Diagnostics.Process.Start(@"https://bitchat.im/"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /BitChatAppMono/frmAddTracker.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp 2 | { 3 | partial class frmAddTracker 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label3 = new System.Windows.Forms.Label(); 32 | this.txtTrackerURL = new System.Windows.Forms.TextBox(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.btnCancel = new System.Windows.Forms.Button(); 35 | this.btnOK = new System.Windows.Forms.Button(); 36 | this.SuspendLayout(); 37 | // 38 | // label3 39 | // 40 | this.label3.AutoSize = true; 41 | this.label3.Location = new System.Drawing.Point(104, 94); 42 | this.label3.Name = "label3"; 43 | this.label3.Size = new System.Drawing.Size(194, 13); 44 | this.label3.TabIndex = 9; 45 | this.label3.Text = "example: udp://tracker.publicbt.com:80"; 46 | // 47 | // txtTrackerURL 48 | // 49 | this.txtTrackerURL.Location = new System.Drawing.Point(107, 23); 50 | this.txtTrackerURL.Multiline = true; 51 | this.txtTrackerURL.Name = "txtTrackerURL"; 52 | this.txtTrackerURL.ScrollBars = System.Windows.Forms.ScrollBars.Both; 53 | this.txtTrackerURL.Size = new System.Drawing.Size(311, 68); 54 | this.txtTrackerURL.TabIndex = 8; 55 | // 56 | // label1 57 | // 58 | this.label1.AutoSize = true; 59 | this.label1.Location = new System.Drawing.Point(27, 26); 60 | this.label1.Name = "label1"; 61 | this.label1.Size = new System.Drawing.Size(74, 13); 62 | this.label1.TabIndex = 7; 63 | this.label1.Text = "Tracker URLs"; 64 | // 65 | // btnCancel 66 | // 67 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 68 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 69 | this.btnCancel.Location = new System.Drawing.Point(366, 118); 70 | this.btnCancel.Name = "btnCancel"; 71 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 72 | this.btnCancel.TabIndex = 11; 73 | this.btnCancel.Text = "Close"; 74 | this.btnCancel.UseVisualStyleBackColor = true; 75 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 76 | // 77 | // btnOK 78 | // 79 | this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 80 | this.btnOK.Location = new System.Drawing.Point(285, 118); 81 | this.btnOK.Name = "btnOK"; 82 | this.btnOK.Size = new System.Drawing.Size(75, 23); 83 | this.btnOK.TabIndex = 10; 84 | this.btnOK.Text = "Add"; 85 | this.btnOK.UseVisualStyleBackColor = true; 86 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click); 87 | // 88 | // frmAddTracker 89 | // 90 | this.AcceptButton = this.btnOK; 91 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 92 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 93 | this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(250)))), ((int)(((byte)(250)))), ((int)(((byte)(250))))); 94 | this.CancelButton = this.btnCancel; 95 | this.ClientSize = new System.Drawing.Size(453, 148); 96 | this.Controls.Add(this.btnCancel); 97 | this.Controls.Add(this.btnOK); 98 | this.Controls.Add(this.label3); 99 | this.Controls.Add(this.txtTrackerURL); 100 | this.Controls.Add(this.label1); 101 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 102 | this.MaximizeBox = false; 103 | this.MinimizeBox = false; 104 | this.Name = "frmAddTracker"; 105 | this.ShowIcon = false; 106 | this.ShowInTaskbar = false; 107 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 108 | this.Text = "Add Tracker"; 109 | this.ResumeLayout(false); 110 | this.PerformLayout(); 111 | 112 | } 113 | 114 | #endregion 115 | 116 | private System.Windows.Forms.Label label3; 117 | public System.Windows.Forms.TextBox txtTrackerURL; 118 | private System.Windows.Forms.Label label1; 119 | private System.Windows.Forms.Button btnCancel; 120 | private System.Windows.Forms.Button btnOK; 121 | } 122 | } -------------------------------------------------------------------------------- /BitChatAppMono/frmAddTracker.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.ComponentModel; 23 | using System.Drawing; 24 | using System.Linq; 25 | using System.Text; 26 | using System.Windows.Forms; 27 | 28 | namespace BitChatApp 29 | { 30 | public partial class frmAddTracker : Form 31 | { 32 | List _trackerUriList = new List(); 33 | 34 | public frmAddTracker(Uri[] trackers = null) 35 | { 36 | InitializeComponent(); 37 | 38 | if (trackers != null) 39 | { 40 | foreach (Uri tracker in trackers) 41 | { 42 | txtTrackerURL.Text += tracker.AbsoluteUri + "\r\n"; 43 | } 44 | } 45 | } 46 | 47 | private void btnCancel_Click(object sender, EventArgs e) 48 | { 49 | this.Close(); 50 | } 51 | 52 | private void btnOK_Click(object sender, EventArgs e) 53 | { 54 | try 55 | { 56 | string[] uriList = txtTrackerURL.Text.Split(new char[] { ' ', ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); 57 | 58 | foreach (string uri in uriList) 59 | _trackerUriList.Add(new Uri(uri)); 60 | } 61 | catch 62 | { 63 | MessageBox.Show("The tracker URL format is invalid. Please enter a valid tracker URL. Multiple URLs must be separated using space, comma or new line.", "Invalid Tracker URL", MessageBoxButtons.OK, MessageBoxIcon.Error); 64 | return; 65 | } 66 | 67 | this.DialogResult = System.Windows.Forms.DialogResult.OK; 68 | this.Close(); 69 | } 70 | 71 | public List TrackerUriList 72 | { get { return _trackerUriList; } } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /BitChatAppMono/frmImportPEM.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Security.Cryptography; 8 | using System.Text; 9 | using System.Windows.Forms; 10 | using TechnitiumLibrary.Security.Cryptography; 11 | 12 | namespace BitChatApp 13 | { 14 | public partial class frmImportPEM : Form 15 | { 16 | #region variables 17 | 18 | RSAParameters _parameters; 19 | 20 | #endregion 21 | 22 | #region form code 23 | 24 | public frmImportPEM() 25 | { 26 | InitializeComponent(); 27 | } 28 | 29 | private void txtRSAKey_TextChanged(object sender, EventArgs e) 30 | { 31 | if (!txtRSAKey.Text.Contains("\r\n")) 32 | txtRSAKey.Text = txtRSAKey.Text.Replace("\n", "\r\n"); 33 | } 34 | 35 | private void btnOK_Click(object sender, EventArgs e) 36 | { 37 | try 38 | { 39 | using (MemoryStream mS = new MemoryStream(Encoding.UTF8.GetBytes(txtRSAKey.Text))) 40 | { 41 | _parameters = PEMFormat.ReadRSAPrivateKey(mS); 42 | } 43 | 44 | using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider()) 45 | { 46 | rsa.ImportParameters(_parameters); 47 | 48 | if (rsa.KeySize < 4096) 49 | { 50 | MessageBox.Show("The RSA private key must be at least 4096-bit. The current key is " + rsa.KeySize + "-bit.", "Short RSA Private Key", MessageBoxButtons.OK, MessageBoxIcon.Error); 51 | return; 52 | } 53 | } 54 | 55 | this.DialogResult = System.Windows.Forms.DialogResult.OK; 56 | this.Close(); 57 | } 58 | catch 59 | { 60 | MessageBox.Show("Error in reading PEM format. Please make sure you have pasted the RSA private key in a proper PEM format.", "Invalid PEM Format", MessageBoxButtons.OK, MessageBoxIcon.Error); 61 | } 62 | } 63 | 64 | private void btnCancel_Click(object sender, EventArgs e) 65 | { 66 | this.Close(); 67 | } 68 | 69 | #endregion 70 | 71 | #region properties 72 | 73 | public RSAParameters Parameters 74 | { get { return _parameters; } } 75 | 76 | #endregion 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /BitChatAppMono/frmMessageInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatApp.UserControls; 21 | using BitChatCore; 22 | using System; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp 26 | { 27 | public partial class frmMessageInfo : Form 28 | { 29 | ChatMessageTextItem chatMessageDisplay; 30 | MessageItem _message; 31 | 32 | public frmMessageInfo(BitChat.Peer selfPeer, MessageItem message) 33 | { 34 | _message = message; 35 | 36 | this.SuspendLayout(); 37 | 38 | InitializeComponent(); 39 | 40 | chatMessageDisplay = new ChatMessageTextItem(selfPeer, _message); 41 | chatMessageDisplay.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; 42 | chatMessageDisplay.Width = chatMessagePanel.Width - 30; 43 | chatMessageDisplay.ContextMenuStrip = null; 44 | 45 | if (chatMessageDisplay.Height > 150) 46 | { 47 | chatMessagePanel.Height = 140; 48 | } 49 | else 50 | { 51 | chatMessagePanel.Height = chatMessageDisplay.Height + 10; 52 | 53 | int heightDiff = 150 - chatMessagePanel.Height; 54 | 55 | this.Height -= heightDiff; 56 | listView1.Top -= heightDiff; 57 | btnClose.Top -= heightDiff; 58 | } 59 | 60 | chatMessagePanel.Controls.Add(chatMessageDisplay); 61 | 62 | this.ResumeLayout(); 63 | } 64 | 65 | private void frmMessageInfo_Load(object sender, EventArgs e) 66 | { 67 | foreach (MessageRecipient rcpt in _message.Recipients) 68 | { 69 | ListViewItem item = listView1.Items.Add(rcpt.Name); 70 | 71 | switch (rcpt.Status) 72 | { 73 | case MessageRecipientStatus.Delivered: 74 | item.SubItems.Add("Delivered on " + rcpt.DeliveredOn.ToLocalTime().ToString()); 75 | break; 76 | 77 | case MessageRecipientStatus.Undelivered: 78 | item.SubItems.Add("Undelivered"); 79 | break; 80 | } 81 | } 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /BitChatAppMono/frmPassword.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using System; 22 | using System.IO; 23 | using System.Windows.Forms; 24 | 25 | namespace BitChatApp 26 | { 27 | public partial class frmPassword : Form 28 | { 29 | #region variables 30 | 31 | string _profileFilePath; 32 | bool _isPortableApp; 33 | string _profileFolder; 34 | 35 | BitChatProfile _profile; 36 | 37 | #endregion 38 | 39 | #region constructor 40 | 41 | public frmPassword(string profileFilePath, bool isPortableApp, string profileFolder) 42 | { 43 | InitializeComponent(); 44 | 45 | _profileFilePath = profileFilePath; 46 | _isPortableApp = isPortableApp; 47 | _profileFolder = profileFolder; 48 | 49 | labProfileName.Text = Path.GetFileNameWithoutExtension(_profileFilePath); 50 | } 51 | 52 | #endregion 53 | 54 | #region private 55 | 56 | private void btnOK_Click(object sender, EventArgs e) 57 | { 58 | try 59 | { 60 | using (FileStream fS = new FileStream(_profileFilePath, FileMode.Open, FileAccess.Read)) 61 | { 62 | _profile = new BitChatProfile(fS, txtPassword.Text, _isPortableApp, _profileFolder); 63 | } 64 | 65 | DialogResult = System.Windows.Forms.DialogResult.OK; 66 | this.Close(); 67 | } 68 | catch 69 | { 70 | try 71 | { 72 | using (FileStream fS = new FileStream(_profileFilePath + ".bak", FileMode.Open, FileAccess.Read)) 73 | { 74 | _profile = new BitChatProfile(fS, txtPassword.Text, _isPortableApp, _profileFolder); 75 | } 76 | 77 | DialogResult = System.Windows.Forms.DialogResult.OK; 78 | this.Close(); 79 | } 80 | catch 81 | { 82 | MessageBox.Show("Invalid password or file data tampered. Please try again.", "Invalid Password!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); 83 | 84 | txtPassword.Text = ""; 85 | txtPassword.Focus(); 86 | } 87 | } 88 | } 89 | 90 | private void btnBack_Click(object sender, EventArgs e) 91 | { 92 | this.Close(); 93 | } 94 | 95 | private void lnkForgotPassword_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 96 | { 97 | if (MessageBox.Show("Since the profile password is used to encrypt the profile data, there is no method to recover the encryption password or the profile data.\r\n\r\nTo access Bit Chat, you will need to register a new profile and you can use the same email address for registration. You will lose all your settings and you will have to join all your chats again.\r\n\r\nDo you want to register a new profile now?", "Register New Profile?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) 98 | { 99 | this.DialogResult = System.Windows.Forms.DialogResult.Yes; 100 | this.Close(); 101 | } 102 | } 103 | 104 | #endregion 105 | 106 | #region properties 107 | 108 | public BitChatProfile Profile 109 | { get { return _profile; } } 110 | 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /BitChatAppMono/frmShareFileSelection.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace BitChatApp 2 | { 3 | partial class frmShareFileSelection 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmShareFileSelection)); 32 | this.checkedListBox1 = new System.Windows.Forms.CheckedListBox(); 33 | this.label1 = new System.Windows.Forms.Label(); 34 | this.btnOK = new System.Windows.Forms.Button(); 35 | this.btnCancel = new System.Windows.Forms.Button(); 36 | this.SuspendLayout(); 37 | // 38 | // checkedListBox1 39 | // 40 | this.checkedListBox1.CheckOnClick = true; 41 | this.checkedListBox1.FormattingEnabled = true; 42 | this.checkedListBox1.IntegralHeight = false; 43 | this.checkedListBox1.Location = new System.Drawing.Point(12, 31); 44 | this.checkedListBox1.Name = "checkedListBox1"; 45 | this.checkedListBox1.Size = new System.Drawing.Size(260, 243); 46 | this.checkedListBox1.Sorted = true; 47 | this.checkedListBox1.TabIndex = 0; 48 | // 49 | // label1 50 | // 51 | this.label1.Location = new System.Drawing.Point(9, 11); 52 | this.label1.Name = "label1"; 53 | this.label1.Size = new System.Drawing.Size(260, 15); 54 | this.label1.TabIndex = 1; 55 | this.label1.Text = "Select the chats from below list to share the file:"; 56 | // 57 | // btnOK 58 | // 59 | this.btnOK.Location = new System.Drawing.Point(116, 280); 60 | this.btnOK.Name = "btnOK"; 61 | this.btnOK.Size = new System.Drawing.Size(75, 23); 62 | this.btnOK.TabIndex = 2; 63 | this.btnOK.Text = "OK"; 64 | this.btnOK.UseVisualStyleBackColor = true; 65 | this.btnOK.Click += new System.EventHandler(this.btnOK_Click); 66 | // 67 | // btnCancel 68 | // 69 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 70 | this.btnCancel.Location = new System.Drawing.Point(197, 280); 71 | this.btnCancel.Name = "btnCancel"; 72 | this.btnCancel.Size = new System.Drawing.Size(75, 23); 73 | this.btnCancel.TabIndex = 3; 74 | this.btnCancel.Text = "Cancel"; 75 | this.btnCancel.UseVisualStyleBackColor = true; 76 | this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); 77 | // 78 | // frmShareFileSelection 79 | // 80 | this.AcceptButton = this.btnOK; 81 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 82 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 83 | this.CancelButton = this.btnCancel; 84 | this.ClientSize = new System.Drawing.Size(284, 311); 85 | this.Controls.Add(this.btnCancel); 86 | this.Controls.Add(this.btnOK); 87 | this.Controls.Add(this.label1); 88 | this.Controls.Add(this.checkedListBox1); 89 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 90 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 91 | this.MaximizeBox = false; 92 | this.MinimizeBox = false; 93 | this.Name = "frmShareFileSelection"; 94 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 95 | this.Text = "Share File"; 96 | this.ResumeLayout(false); 97 | 98 | } 99 | 100 | #endregion 101 | 102 | private System.Windows.Forms.CheckedListBox checkedListBox1; 103 | private System.Windows.Forms.Label label1; 104 | private System.Windows.Forms.Button btnOK; 105 | private System.Windows.Forms.Button btnCancel; 106 | } 107 | } -------------------------------------------------------------------------------- /BitChatAppMono/frmShareFileSelection.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using BitChatCore.FileSharing; 22 | using System; 23 | using System.Collections.Generic; 24 | using System.Windows.Forms; 25 | 26 | namespace BitChatApp 27 | { 28 | public partial class frmShareFileSelection : Form 29 | { 30 | List _selectedChats; 31 | 32 | public frmShareFileSelection(BitChatNode node, SharedFile sharedFile) 33 | { 34 | InitializeComponent(); 35 | 36 | BitChat[] sharedChats = sharedFile.GetChatList(); 37 | 38 | foreach (BitChat chat in node.GetBitChatList()) 39 | { 40 | bool found = false; 41 | 42 | foreach (BitChat sharedChat in sharedChats) 43 | { 44 | if (sharedChat == chat) 45 | { 46 | found = true; 47 | break; 48 | } 49 | } 50 | 51 | if (!found) 52 | checkedListBox1.Items.Add(chat); 53 | } 54 | } 55 | 56 | private void btnOK_Click(object sender, EventArgs e) 57 | { 58 | _selectedChats = new List(); 59 | 60 | foreach (BitChat item in checkedListBox1.CheckedItems) 61 | _selectedChats.Add(item); 62 | 63 | DialogResult = DialogResult.OK; 64 | this.Close(); 65 | } 66 | 67 | private void btnCancel_Click(object sender, EventArgs e) 68 | { 69 | DialogResult = DialogResult.Cancel; 70 | this.Close(); 71 | } 72 | 73 | public List SelectedChats 74 | { get { return _selectedChats; } } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /BitChatAppMono/frmWelcome.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using BitChatCore; 21 | using System; 22 | using System.Windows.Forms; 23 | 24 | namespace BitChatApp 25 | { 26 | public partial class frmWelcome : Form 27 | { 28 | #region variables 29 | 30 | bool _isPortableApp; 31 | string _profileFolder; 32 | 33 | BitChatProfile _profile; 34 | string _profileFilePath; 35 | 36 | #endregion 37 | 38 | #region constructors 39 | 40 | public frmWelcome(bool isPortableApp, string profileFolder) 41 | { 42 | InitializeComponent(); 43 | 44 | _isPortableApp = isPortableApp; 45 | _profileFolder = profileFolder; 46 | } 47 | 48 | #endregion 49 | 50 | #region private 51 | 52 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 53 | { 54 | System.Diagnostics.Process.Start("https://bitchat.im"); 55 | } 56 | 57 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 58 | { 59 | System.Diagnostics.Process.Start("http://blog.technitium.com/2015/11/how-to-register-profile-get-started.html"); 60 | } 61 | 62 | private void frmRegisterNow_Click(object sender, EventArgs e) 63 | { 64 | this.Hide(); 65 | 66 | using (frmRegister frm = new frmRegister(_isPortableApp, _profileFolder)) 67 | { 68 | DialogResult result = frm.ShowDialog(this); 69 | 70 | switch (result) 71 | { 72 | case System.Windows.Forms.DialogResult.OK: 73 | _profile = frm.Profile; 74 | _profileFilePath = frm.ProfileFilePath; 75 | 76 | this.DialogResult = System.Windows.Forms.DialogResult.OK; 77 | this.Close(); 78 | break; 79 | 80 | case System.Windows.Forms.DialogResult.Ignore: 81 | this.Show(); 82 | break; 83 | 84 | default: 85 | this.DialogResult = System.Windows.Forms.DialogResult.Cancel; 86 | this.Close(); 87 | break; 88 | } 89 | } 90 | } 91 | 92 | private void btnAlreadyRegistered_Click(object sender, EventArgs e) 93 | { 94 | this.DialogResult = System.Windows.Forms.DialogResult.Ignore; 95 | this.Close(); 96 | } 97 | 98 | #endregion 99 | 100 | #region properties 101 | 102 | public BitChatProfile Profile 103 | { get { return _profile; } } 104 | 105 | public string ProfileFilePath 106 | { get { return _profileFilePath; } } 107 | 108 | #endregion 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /BitChatAppMono/install-mono.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apt-get -y install mono-complete 4 | mozroots --import --ask-remove 5 | -------------------------------------------------------------------------------- /BitChatAppMono/logo2.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/BitChatAppMono/logo2.ico -------------------------------------------------------------------------------- /BitChatAppMono/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sudo mono BitChat.exe& 4 | -------------------------------------------------------------------------------- /BitChatClient.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomaticUpdate.Client", "AutomaticUpdate.Client\AutomaticUpdate.Client.csproj", "{0BC4EAC6-4A90-4126-900D-AB5EB691C3FD}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutomaticUpdate.Update", "AutomaticUpdate.Update\AutomaticUpdate.Update.csproj", "{1A335105-2DA8-4143-A8CB-66A2C6FC1F00}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitChatApp", "BitChatApp\BitChatApp.csproj", "{68ED49DF-C976-4165-9314-EA15C4FAB1A3}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitChatAppMono", "BitChatAppMono\BitChatAppMono.csproj", "{D561478D-7EA2-4066-8EC4-D9DF74E1B190}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BitChatCore", "BitChatCore\BitChatCore.csproj", "{3038B7EA-D974-431F-A6C0-FE7C7E5308A2}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "References", "References", "{3A48DAB9-2590-4514-8BB5-8DFF08B1BF60}" 17 | ProjectSection(SolutionItems) = preProject 18 | References\TechnitiumLibrary.IO.dll = References\TechnitiumLibrary.IO.dll 19 | References\TechnitiumLibrary.Net.BitTorrent.dll = References\TechnitiumLibrary.Net.BitTorrent.dll 20 | References\TechnitiumLibrary.Net.dll = References\TechnitiumLibrary.Net.dll 21 | References\TechnitiumLibrary.Net.Firewall.dll = References\TechnitiumLibrary.Net.Firewall.dll 22 | References\TechnitiumLibrary.Net.UPnP.dll = References\TechnitiumLibrary.Net.UPnP.dll 23 | References\TechnitiumLibrary.Security.Cryptography.dll = References\TechnitiumLibrary.Security.Cryptography.dll 24 | EndProjectSection 25 | EndProject 26 | Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "BitChatAppSetup", "BitChatAppSetup\BitChatAppSetup.vdproj", "{1875E90B-EFE9-4B53-8558-0657D3F72F75}" 27 | EndProject 28 | Global 29 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 30 | Debug|Any CPU = Debug|Any CPU 31 | Release|Any CPU = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 34 | {0BC4EAC6-4A90-4126-900D-AB5EB691C3FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {0BC4EAC6-4A90-4126-900D-AB5EB691C3FD}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {0BC4EAC6-4A90-4126-900D-AB5EB691C3FD}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {0BC4EAC6-4A90-4126-900D-AB5EB691C3FD}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {1A335105-2DA8-4143-A8CB-66A2C6FC1F00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {1A335105-2DA8-4143-A8CB-66A2C6FC1F00}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {1A335105-2DA8-4143-A8CB-66A2C6FC1F00}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {1A335105-2DA8-4143-A8CB-66A2C6FC1F00}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {68ED49DF-C976-4165-9314-EA15C4FAB1A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {68ED49DF-C976-4165-9314-EA15C4FAB1A3}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {68ED49DF-C976-4165-9314-EA15C4FAB1A3}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {68ED49DF-C976-4165-9314-EA15C4FAB1A3}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {D561478D-7EA2-4066-8EC4-D9DF74E1B190}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {D561478D-7EA2-4066-8EC4-D9DF74E1B190}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {D561478D-7EA2-4066-8EC4-D9DF74E1B190}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {D561478D-7EA2-4066-8EC4-D9DF74E1B190}.Release|Any CPU.Build.0 = Release|Any CPU 50 | {3038B7EA-D974-431F-A6C0-FE7C7E5308A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 | {3038B7EA-D974-431F-A6C0-FE7C7E5308A2}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 | {3038B7EA-D974-431F-A6C0-FE7C7E5308A2}.Release|Any CPU.ActiveCfg = Release|Any CPU 53 | {3038B7EA-D974-431F-A6C0-FE7C7E5308A2}.Release|Any CPU.Build.0 = Release|Any CPU 54 | {1875E90B-EFE9-4B53-8558-0657D3F72F75}.Debug|Any CPU.ActiveCfg = Debug 55 | {1875E90B-EFE9-4B53-8558-0657D3F72F75}.Debug|Any CPU.Build.0 = Debug 56 | {1875E90B-EFE9-4B53-8558-0657D3F72F75}.Release|Any CPU.ActiveCfg = Release 57 | {1875E90B-EFE9-4B53-8558-0657D3F72F75}.Release|Any CPU.Build.0 = Release 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | EndGlobal 63 | -------------------------------------------------------------------------------- /BitChatCore/BitChatCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {3038B7EA-D974-431F-A6C0-FE7C7E5308A2} 8 | Library 9 | Properties 10 | BitChatCore 11 | BitChatCore 12 | v4.0 13 | 512 14 | 15 | 16 | 17 | 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | false 26 | 27 | 28 | full 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | false 35 | true 36 | 37 | 38 | 39 | 40 | 41 | False 42 | ..\References\TechnitiumLibrary.IO.dll 43 | 44 | 45 | False 46 | ..\References\TechnitiumLibrary.Net.dll 47 | 48 | 49 | False 50 | ..\References\TechnitiumLibrary.Net.BitTorrent.dll 51 | 52 | 53 | False 54 | ..\References\TechnitiumLibrary.Net.UPnP.dll 55 | 56 | 57 | False 58 | ..\References\TechnitiumLibrary.Security.Cryptography.dll 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 104 | -------------------------------------------------------------------------------- /BitChatCore/BitChatException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | 22 | namespace BitChatCore 23 | { 24 | [Serializable()] 25 | public class BitChatException : Exception 26 | { 27 | public BitChatException() 28 | { } 29 | 30 | public BitChatException(string message) 31 | : base(message) 32 | { } 33 | 34 | public BitChatException(string message, Exception innerException) 35 | : base(message, innerException) 36 | { } 37 | 38 | public BitChatException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) 39 | : base(info, context) 40 | { } 41 | } 42 | } -------------------------------------------------------------------------------- /BitChatCore/Debug.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | 22 | namespace BitChatCore 23 | { 24 | public static class Debug 25 | { 26 | #region variables 27 | 28 | static object _lockObj = new object(); 29 | static IDebug _debug; 30 | 31 | #endregion 32 | 33 | #region public static 34 | 35 | public static void SetDebug(IDebug debug) 36 | { 37 | _debug = debug; 38 | } 39 | 40 | public static void Write(string source, Exception ex) 41 | { 42 | if (_debug != null) 43 | { 44 | lock (_lockObj) 45 | { 46 | _debug.Write(DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss") + "\t" + source + "\t" + ex.Message + "\r\nStack Trace: \r\n\t" + ex.StackTrace + "\r\n\r\n"); 47 | } 48 | } 49 | } 50 | 51 | public static void Write(string source, string message) 52 | { 53 | if (_debug != null) 54 | { 55 | lock (_lockObj) 56 | { 57 | _debug.Write(DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss") + "\t" + source + "\t" + message + "\r\n\r\n"); 58 | } 59 | } 60 | } 61 | 62 | #endregion 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /BitChatCore/IDebug.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | 21 | namespace BitChatCore 22 | { 23 | public interface IDebug 24 | { 25 | void Write(string message); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /BitChatCore/MessageRecipient.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2016 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.IO; 22 | using TechnitiumLibrary.IO; 23 | 24 | namespace BitChatCore 25 | { 26 | public enum MessageRecipientStatus : byte 27 | { 28 | Undelivered = 0, 29 | Delivered = 1 30 | } 31 | 32 | public class MessageRecipient : IWriteStream 33 | { 34 | #region variables 35 | 36 | readonly string _name; 37 | 38 | MessageRecipientStatus _status = MessageRecipientStatus.Undelivered; 39 | DateTime _deliveredOn; 40 | 41 | #endregion 42 | 43 | #region constructor 44 | 45 | public MessageRecipient(string name) 46 | { 47 | _name = name; 48 | } 49 | 50 | public MessageRecipient(Stream s) 51 | { 52 | BincodingDecoder decoder = new BincodingDecoder(s); 53 | 54 | switch (decoder.DecodeNext().GetByteValue()) //version 55 | { 56 | case 1: 57 | _name = decoder.DecodeNext().GetStringValue(); 58 | _status = (MessageRecipientStatus)decoder.DecodeNext().GetByteValue(); 59 | _deliveredOn = decoder.DecodeNext().GetDateTimeValue(); 60 | break; 61 | 62 | default: 63 | throw new InvalidDataException("Cannot decode data format: version not supported."); 64 | } 65 | } 66 | 67 | #endregion 68 | 69 | #region public 70 | 71 | public void SetDeliveredStatus() 72 | { 73 | _status = MessageRecipientStatus.Delivered; 74 | _deliveredOn = DateTime.UtcNow; 75 | } 76 | 77 | public void WriteTo(Stream s) 78 | { 79 | BincodingEncoder encoder = new BincodingEncoder(s); 80 | 81 | encoder.Encode((byte)1); //version 82 | encoder.Encode(_name); 83 | encoder.Encode((byte)_status); 84 | encoder.Encode(_deliveredOn); 85 | } 86 | 87 | #endregion 88 | 89 | #region properties 90 | 91 | public string Name 92 | { get { return _name; } } 93 | 94 | public MessageRecipientStatus Status 95 | { get { return _status; } } 96 | 97 | public DateTime DeliveredOn 98 | { get { return _deliveredOn; } } 99 | 100 | #endregion 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /BitChatCore/Network/KademliaDHT/IDhtNodeManager.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2017 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System.IO; 21 | using System.Net; 22 | 23 | namespace BitChatCore.Network.KademliaDHT 24 | { 25 | interface IDhtNodeManager 26 | { 27 | Stream GetConnectionStream(IPEndPoint remoteNodeEP); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BitChatCore/Network/KademliaDHT/NodeContact.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2017 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.IO; 22 | using System.Net; 23 | using System.Security.Cryptography; 24 | using TechnitiumLibrary.IO; 25 | using TechnitiumLibrary.Net; 26 | 27 | namespace BitChatCore.Network.KademliaDHT 28 | { 29 | class NodeContact : IWriteStream, IComparable 30 | { 31 | #region variables 32 | 33 | const int NODE_RPC_FAIL_LIMIT = 5; //max failed RPC count before declaring node stale 34 | const int NODE_STALE_TIMEOUT_SECONDS = 900; //15mins timeout before declaring node stale 35 | 36 | static readonly byte[] NODE_ID_SALT = new byte[] { 0xF4, 0xC7, 0x56, 0x9A, 0xA3, 0xAD, 0xC9, 0xA7, 0x13, 0x0E, 0xCA, 0x56, 0x56, 0xA3, 0x52, 0x8F, 0xFE, 0x6E, 0x9C, 0x72 }; 37 | 38 | readonly IPEndPoint _nodeEP; 39 | readonly BinaryNumber _nodeID; 40 | 41 | protected bool _currentNode; 42 | DateTime _lastSeen; 43 | int _failRpcCount = 0; 44 | 45 | #endregion 46 | 47 | #region constructor 48 | 49 | public NodeContact(Stream s) 50 | { 51 | _nodeEP = IPEndPointParser.Parse(s); 52 | _nodeID = GetNodeID(_nodeEP); 53 | } 54 | 55 | public NodeContact(IPEndPoint nodeEP) 56 | { 57 | _nodeEP = nodeEP; 58 | _nodeID = GetNodeID(_nodeEP); 59 | } 60 | 61 | #endregion 62 | 63 | #region static 64 | 65 | public static BinaryNumber GetNodeID(IPEndPoint nodeEP) 66 | { 67 | using (HMAC hmac = new HMACSHA1(NODE_ID_SALT)) 68 | { 69 | using (MemoryStream mS = new MemoryStream(20)) 70 | { 71 | IPEndPointParser.WriteTo(nodeEP, mS); 72 | mS.Position = 0; 73 | 74 | return new BinaryNumber(hmac.ComputeHash(mS)); 75 | } 76 | } 77 | } 78 | 79 | #endregion 80 | 81 | #region public 82 | 83 | public bool IsStale() 84 | { 85 | if (_currentNode) 86 | return false; 87 | else 88 | return ((_failRpcCount > NODE_RPC_FAIL_LIMIT) || ((DateTime.UtcNow - _lastSeen).TotalSeconds > NODE_STALE_TIMEOUT_SECONDS)); 89 | } 90 | 91 | public void UpdateLastSeenTime() 92 | { 93 | _lastSeen = DateTime.UtcNow; 94 | _failRpcCount = 0; 95 | } 96 | 97 | public void IncrementRpcFailCount() 98 | { 99 | _failRpcCount++; 100 | } 101 | 102 | public void WriteTo(Stream s) 103 | { 104 | IPEndPointParser.WriteTo(_nodeEP, s); 105 | } 106 | 107 | public override bool Equals(object obj) 108 | { 109 | NodeContact contact = obj as NodeContact; 110 | 111 | if (contact == null) 112 | return false; 113 | 114 | return Equals(_nodeID, contact._nodeID); 115 | } 116 | 117 | public override int GetHashCode() 118 | { 119 | return _nodeID.GetHashCode(); 120 | } 121 | 122 | public int CompareTo(NodeContact other) 123 | { 124 | return _lastSeen.CompareTo(other._lastSeen); 125 | } 126 | 127 | public override string ToString() 128 | { 129 | return _nodeEP.ToString(); 130 | } 131 | 132 | #endregion 133 | 134 | #region properties 135 | 136 | public BinaryNumber NodeID 137 | { get { return _nodeID; } } 138 | 139 | public IPEndPoint NodeEP 140 | { get { return _nodeEP; } } 141 | 142 | public bool IsCurrentNode 143 | { get { return _currentNode; } } 144 | 145 | public DateTime LastSeen 146 | { get { return _lastSeen; } } 147 | 148 | #endregion 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /BitChatCore/Network/KademliaDHT/PeerEndPoint.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2017 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.IO; 22 | using System.Net; 23 | using TechnitiumLibrary.Net; 24 | 25 | namespace BitChatCore.Network.KademliaDHT 26 | { 27 | class PeerEndPoint : IPEndPoint 28 | { 29 | #region variables 30 | 31 | const int PEER_EXPIRY_TIME_SECONDS = 900; //15 min expiry 32 | 33 | DateTime _dateAdded = DateTime.UtcNow; 34 | 35 | #endregion 36 | 37 | #region constructor 38 | 39 | public PeerEndPoint(IPAddress address, int port) 40 | : base(address, port) 41 | { } 42 | 43 | public PeerEndPoint(Stream s) 44 | : base(0, 0) 45 | { 46 | IPEndPoint ep = IPEndPointParser.Parse(s); 47 | 48 | this.Address = ep.Address; 49 | this.Port = ep.Port; 50 | } 51 | 52 | #endregion 53 | 54 | #region public 55 | 56 | public bool HasExpired() 57 | { 58 | return (DateTime.UtcNow - _dateAdded).TotalSeconds > PEER_EXPIRY_TIME_SECONDS; 59 | } 60 | 61 | public void UpdateDateAdded() 62 | { 63 | _dateAdded = DateTime.UtcNow; 64 | } 65 | 66 | public void WriteTo(Stream s) 67 | { 68 | IPEndPointParser.WriteTo(this, s); 69 | } 70 | 71 | #endregion 72 | 73 | #region properties 74 | 75 | public DateTime DateAdded 76 | { get { return _dateAdded; } } 77 | 78 | #endregion 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /BitChatCore/Network/PeerInfo.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2017 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.Collections.Generic; 22 | using System.IO; 23 | using System.Net; 24 | using System.Text; 25 | using TechnitiumLibrary.IO; 26 | using TechnitiumLibrary.Net; 27 | 28 | namespace BitChatCore.Network 29 | { 30 | public class PeerInfo : IWriteStream 31 | { 32 | #region variables 33 | 34 | string _peerEmail; 35 | List _peerEPList; 36 | 37 | #endregion 38 | 39 | #region constructor 40 | 41 | public PeerInfo(string peerEmail, List peerEPList) 42 | { 43 | _peerEmail = peerEmail.ToLower(); 44 | _peerEPList = peerEPList; 45 | } 46 | 47 | public PeerInfo(Stream s) 48 | { 49 | byte[] buffer = new byte[s.ReadByte()]; 50 | OffsetStream.StreamRead(s, buffer, 0, buffer.Length); 51 | _peerEmail = Encoding.UTF8.GetString(buffer); 52 | 53 | int count = s.ReadByte(); 54 | _peerEPList = new List(count); 55 | 56 | for (int i = 0; i < count; i++) 57 | _peerEPList.Add(IPEndPointParser.Parse(s)); 58 | } 59 | 60 | #endregion 61 | 62 | #region public 63 | 64 | public void WriteTo(Stream s) 65 | { 66 | byte[] buffer = Encoding.UTF8.GetBytes(_peerEmail); 67 | 68 | s.WriteByte(Convert.ToByte(buffer.Length)); 69 | s.Write(buffer, 0, buffer.Length); 70 | 71 | s.WriteByte(Convert.ToByte(_peerEPList.Count)); 72 | 73 | foreach (IPEndPoint peerEP in _peerEPList) 74 | IPEndPointParser.WriteTo(peerEP, s); 75 | } 76 | 77 | public override bool Equals(object obj) 78 | { 79 | if (ReferenceEquals(null, obj)) 80 | return false; 81 | 82 | if (ReferenceEquals(this, obj)) 83 | return true; 84 | 85 | PeerInfo objPeerInfo = obj as PeerInfo; 86 | 87 | return _peerEmail.Equals(objPeerInfo._peerEmail); 88 | } 89 | 90 | public override int GetHashCode() 91 | { 92 | return _peerEmail.GetHashCode(); 93 | } 94 | 95 | #endregion 96 | 97 | #region properties 98 | 99 | public string PeerEmail 100 | { get { return _peerEmail; } } 101 | 102 | public List PeerEPList 103 | { get { return _peerEPList; } } 104 | 105 | #endregion 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /BitChatCore/Network/SecureChannel/ISecureChannelSecurityManager.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using TechnitiumLibrary.Security.Cryptography; 21 | 22 | namespace BitChatCore.Network.SecureChannel 23 | { 24 | interface ISecureChannelSecurityManager 25 | { 26 | bool ProceedConnection(Certificate remoteCertificate); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BitChatCore/Network/SecureChannel/SecureChannelException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | Technitium Bit Chat 3 | Copyright (C) 2015 Shreyas Zare (shreyas@technitium.com) 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | 18 | */ 19 | 20 | using System; 21 | using System.IO; 22 | using System.Net; 23 | using TechnitiumLibrary.Security.Cryptography; 24 | 25 | namespace BitChatCore.Network.SecureChannel 26 | { 27 | public enum SecureChannelCode : byte 28 | { 29 | None = 0, 30 | RemoteError = 1, 31 | ProtocolVersionNotSupported = 2, 32 | NoMatchingCryptoAvailable = 3, 33 | SecurityManagerDeclinedAccess = 4, 34 | InvalidRemoteCertificate = 5, 35 | InvalidRemoteCertificateAlgorithm = 6, 36 | InvalidRemoteKeyExchangeSignature = 7, 37 | InvalidMessageHMACReceived = 8, 38 | ProtocolAuthenticationFailed = 9, 39 | UnknownException = 254, 40 | } 41 | 42 | [Serializable()] 43 | public class SecureChannelException : IOException 44 | { 45 | #region variable 46 | 47 | SecureChannelCode _code; 48 | IPEndPoint _peerEP; 49 | Certificate _peerCertificate; 50 | 51 | #endregion 52 | 53 | #region constructor 54 | 55 | public SecureChannelException(SecureChannelCode code, IPEndPoint peerEP, Certificate peerCertificate) 56 | { 57 | _code = code; 58 | _peerEP = peerEP; 59 | _peerCertificate = peerCertificate; 60 | } 61 | 62 | public SecureChannelException(SecureChannelCode code, IPEndPoint peerEP, Certificate peerCertificate, string message) 63 | : base(message) 64 | { 65 | _code = code; 66 | _peerEP = peerEP; 67 | _peerCertificate = peerCertificate; 68 | } 69 | 70 | public SecureChannelException(SecureChannelCode code, IPEndPoint peerEP, Certificate peerCertificate, string message, Exception innerException) 71 | : base(message, innerException) 72 | { 73 | _code = code; 74 | _peerEP = peerEP; 75 | _peerCertificate = peerCertificate; 76 | } 77 | 78 | public SecureChannelException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) 79 | : base(info, context) 80 | { } 81 | 82 | #endregion 83 | 84 | #region property 85 | 86 | public SecureChannelCode Code 87 | { get { return _code; } } 88 | 89 | public IPEndPoint PeerEP 90 | { get { return _peerEP; } } 91 | 92 | public Certificate PeerCertificate 93 | { get { return _peerCertificate; } } 94 | 95 | #endregion 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /BitChatCore/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("Bit Chat")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Technitium")] 12 | [assembly: AssemblyProduct("Bit Chat")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 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("1a38d84a-7281-4667-a1ba-de0470a6b8a4")] 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("4.6.3.0")] 36 | [assembly: AssemblyFileVersion("4.6.3.0")] 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BitChatClient 2 | Technitium Bit Chat is a secure, peer-to-peer (p2p), open source instant messenger designed to provide end-to-end encryption. Primary aim of developing this instant messenger is to provide privacy which is achieved using strong cryptography. It can be used over Internet and private LAN networks for instant messaging and file transfer. 3 | 4 | The architecture is designed keeping in mind the security principle that everybody is secure or no one is. There is no meta data generated when you use Bit Chat. The only thing that we know, is the email address of the user who registered for a digital certificate. The digital certificate tells that the email address was verified, which is similar, in concept, to any domain validated SSL certificate issued to a website. 5 | 6 | Development is still in progress and new features will be made available as an when they are coded. The software has automatic update feature which will keep you updated with latest version available. 7 | 8 | Website: https://bitchat.im 9 | 10 | Read more: http://blog.technitium.com/2015/05/technitium-bit-chat-released.html -------------------------------------------------------------------------------- /References/TechnitiumLibrary.IO.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/References/TechnitiumLibrary.IO.dll -------------------------------------------------------------------------------- /References/TechnitiumLibrary.Net.BitTorrent.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/References/TechnitiumLibrary.Net.BitTorrent.dll -------------------------------------------------------------------------------- /References/TechnitiumLibrary.Net.Firewall.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/References/TechnitiumLibrary.Net.Firewall.dll -------------------------------------------------------------------------------- /References/TechnitiumLibrary.Net.UPnP.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/References/TechnitiumLibrary.Net.UPnP.dll -------------------------------------------------------------------------------- /References/TechnitiumLibrary.Net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/References/TechnitiumLibrary.Net.dll -------------------------------------------------------------------------------- /References/TechnitiumLibrary.Security.Cryptography.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TechnitiumSoftware/BitChatClient/50d2c949b598e1abaa5088442055f4962f7f0b53/References/TechnitiumLibrary.Security.Cryptography.dll --------------------------------------------------------------------------------