├── puush-win.txt
├── success.wav
├── icon-upload.png
├── icon-window.png
├── iconbundle.ico
├── quickstart.png
├── Progress
├── fail.ico
├── tray.ico
├── complete.ico
├── progress0.ico
├── progress10.ico
├── progress20.ico
├── progress30.ico
├── progress40.ico
├── progress50.ico
├── progress60.ico
├── progress70.ico
├── progress80.ico
├── progress90.ico
└── progress100.ico
├── icon-selection.png
├── Resources
└── puush.png
├── icon-fullscreen.png
├── Libraries
├── Hooking
│ ├── HookManager.Windows.cs
│ ├── MouseEventExtArgs.cs
│ └── HookManager.Structures.cs
├── NetLib
│ ├── HttpVersion.cs
│ ├── AuthenticationType.cs
│ ├── SetFlagsMethod.cs
│ ├── NetworkStreamAction.cs
│ ├── TcpListEventHandler.cs
│ ├── TcpTextEventHandler.cs
│ ├── DataAddedEventHandler.cs
│ ├── HttpRedirectEventHandler.cs
│ ├── HttpRequestEventHandler.cs
│ ├── HttpResponseEventHandler.cs
│ ├── GetDataStreamEventHandler.cs
│ ├── SocketProgressEventHandler.cs
│ ├── SymbolType.cs
│ ├── AsyncAcceptStatusObject.cs
│ ├── StreamError.cs
│ ├── TcpTextEventArgs.cs
│ ├── TcpListEventArgs.cs
│ ├── AsyncStatusObject.cs
│ ├── HeaderField.cs
│ ├── HostInfo.cs
│ ├── HttpError.cs
│ ├── SocketProgressEventArgs.cs
│ ├── DataAddedEventArgs.cs
│ ├── HttpRequestUtils.cs
│ ├── GetDataStreamEventArgs.cs
│ ├── HttpRequestEventArgs.cs
│ ├── StringStream.cs
│ ├── StreamUtils.cs
│ ├── SocketError.cs
│ ├── Translator.cs
│ ├── HttpResponseEventArgs.cs
│ ├── BinaryRequestItem.cs
│ ├── HttpProxySettings.cs
│ ├── TextRequestItem.cs
│ ├── TcpClientConnection.cs
│ ├── DataNetRequest.cs
│ ├── HostList.cs
│ ├── Utils.cs
│ ├── NetRequest.cs
│ ├── HttpRedirectEventArgs.cs
│ ├── CookieItem.cs
│ ├── StringNetRequest.cs
│ ├── FormFieldRequestItem.cs
│ ├── FormDataNetRequest.cs
│ ├── FormNetRequest.cs
│ ├── HttpRequestItem.cs
│ ├── NetManager.cs
│ ├── FileUploadNetRequest.cs
│ ├── MultiStream.cs
│ ├── StringCollectionEx.cs
│ ├── FileNetRequest.cs
│ ├── UrlParser.cs
│ ├── HttpRequestItemList.cs
│ ├── NetworkStream.cs
│ ├── CookieList.cs
│ └── SubmitFileRequestItem.cs
├── TopMostMessageBox.cs
├── SharpZipLib
│ ├── Core
│ │ ├── IScanFilter.cs
│ │ └── INameTransform.cs
│ ├── Zip
│ │ ├── Compression
│ │ │ └── DeflaterPending.cs
│ │ ├── ZipException.cs
│ │ └── IEntryFactory.cs
│ ├── BZip2
│ │ └── BZip2Exception.cs
│ ├── Checksums
│ │ └── IChecksum.cs
│ └── SharpZipBaseException.cs
├── pForm.cs
├── CryptoHelper.cs
└── pConfigManager.cs
├── README.md
├── puush.tlp
├── puush.csproj.DotSettings.user
├── puush.csproj.user
├── ScreenSelection.cs
├── puush.sln
├── ToolStripItemThumbnail.cs
├── Properties
└── AssemblyInfo.cs
├── UpdateAvailableDialog.cs
├── ScreenSelection.Designer.cs
├── IPC.cs
├── Settings.BindingCapture.cs
├── GlobalHotKey.cs
├── .gitignore
├── HistoryManager.cs
├── MainForm.Capture.cs
├── QuickStart.cs
├── UpdateAvailableDialog.Designer.cs
├── ScreenshotCapture.cs
├── HistoryItem.cs
├── ContextMenuHandler.cs
├── DockedPanel.resx
└── QuickStart.resx
/puush-win.txt:
--------------------------------------------------------------------------------
1 | something's supposed to be here
--------------------------------------------------------------------------------
/success.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/success.wav
--------------------------------------------------------------------------------
/icon-upload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/icon-upload.png
--------------------------------------------------------------------------------
/icon-window.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/icon-window.png
--------------------------------------------------------------------------------
/iconbundle.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/iconbundle.ico
--------------------------------------------------------------------------------
/quickstart.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/quickstart.png
--------------------------------------------------------------------------------
/Progress/fail.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/fail.ico
--------------------------------------------------------------------------------
/Progress/tray.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/tray.ico
--------------------------------------------------------------------------------
/icon-selection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/icon-selection.png
--------------------------------------------------------------------------------
/Resources/puush.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Resources/puush.png
--------------------------------------------------------------------------------
/icon-fullscreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/icon-fullscreen.png
--------------------------------------------------------------------------------
/Progress/complete.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/complete.ico
--------------------------------------------------------------------------------
/Progress/progress0.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress0.ico
--------------------------------------------------------------------------------
/Progress/progress10.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress10.ico
--------------------------------------------------------------------------------
/Progress/progress20.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress20.ico
--------------------------------------------------------------------------------
/Progress/progress30.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress30.ico
--------------------------------------------------------------------------------
/Progress/progress40.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress40.ico
--------------------------------------------------------------------------------
/Progress/progress50.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress50.ico
--------------------------------------------------------------------------------
/Progress/progress60.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress60.ico
--------------------------------------------------------------------------------
/Progress/progress70.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress70.ico
--------------------------------------------------------------------------------
/Progress/progress80.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress80.ico
--------------------------------------------------------------------------------
/Progress/progress90.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress90.ico
--------------------------------------------------------------------------------
/Progress/progress100.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Progress/progress100.ico
--------------------------------------------------------------------------------
/Libraries/Hooking/HookManager.Windows.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peppy/puush-client-windows/HEAD/Libraries/Hooking/HookManager.Windows.cs
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # puush-client-windows
2 |
3 | provided as-is. can use for whatever but please remove puush branding if redistributing.
4 |
5 | don't trip over the ancient code.
6 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpVersion.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public enum HttpVersion
6 | {
7 | Http1_0,
8 | Http1_1
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/Libraries/NetLib/AuthenticationType.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public enum AuthenticationType
6 | {
7 | Basic,
8 | AutoDetect
9 | }
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/Libraries/NetLib/SetFlagsMethod.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public enum SetFlagsMethod
6 | {
7 | Replace,
8 | Add,
9 | Remove
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/Libraries/NetLib/NetworkStreamAction.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public enum NetworkStreamAction
6 | {
7 | None,
8 | Read,
9 | Write
10 | }
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/Libraries/NetLib/TcpListEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void TcpListEventHandler(object sender, TcpListEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/TcpTextEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void TcpTextEventHandler(object sender, TcpTextEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/DataAddedEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void DataAddedEventHandler(object sender, DataAddedEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRedirectEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void HttpRedirectEventHandler(object sender, HttpRedirectEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRequestEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void HttpRequestEventHandler(object sender, HttpRequestEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpResponseEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void HttpResponseEventHandler(object sender, HttpResponseEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/puush.tlp:
--------------------------------------------------------------------------------
1 | Tunnelier 4.29 puush.me puush xterm
127.0.0.1:0.0 127.0.0.1
= , 1080 21
--------------------------------------------------------------------------------
/Libraries/NetLib/GetDataStreamEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void GetDataStreamEventHandler(object sender, GetDataStreamEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/SocketProgressEventHandler.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Runtime.CompilerServices;
5 |
6 | public delegate void SocketProgressEventHandler(object sender, SocketProgressEventArgs e);
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Libraries/NetLib/SymbolType.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | internal enum SymbolType
6 | {
7 | DontCare,
8 | Delimiter,
9 | Separator,
10 | WhiteSpace
11 | }
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/Libraries/NetLib/AsyncAcceptStatusObject.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Sockets;
2 |
3 | namespace osu_common.Libraries.NetLib
4 | {
5 | internal class AsyncAcceptStatusObject : AsyncStatusObject
6 | {
7 | public Socket AcceptedSocket;
8 |
9 | public AsyncAcceptStatusObject(Socket sock) : base(sock)
10 | {
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/StreamError.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class StreamError : Exception
6 | {
7 | public StreamError(string message) : base(message)
8 | {
9 | }
10 |
11 | public StreamError(string message, Exception exception) : base(message, exception)
12 | {
13 | }
14 | }
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/puush.csproj.DotSettings.user:
--------------------------------------------------------------------------------
1 |
2 | True
--------------------------------------------------------------------------------
/Libraries/NetLib/TcpTextEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class TcpTextEventArgs : EventArgs
6 | {
7 | private string text;
8 |
9 | public TcpTextEventArgs(string text)
10 | {
11 | this.text = text;
12 | }
13 |
14 | public string Text
15 | {
16 | get
17 | {
18 | return this.text;
19 | }
20 | }
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Libraries/NetLib/TcpListEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class TcpListEventArgs : EventArgs
6 | {
7 | private DataStringCollection list;
8 |
9 | public TcpListEventArgs(DataStringCollection list)
10 | {
11 | this.list = list;
12 | }
13 |
14 | public DataStringCollection List
15 | {
16 | get
17 | {
18 | return this.list;
19 | }
20 | }
21 | }
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Libraries/NetLib/AsyncStatusObject.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Net.Sockets;
5 | using System.Threading;
6 |
7 | internal class AsyncStatusObject
8 | {
9 | public Exception exception;
10 | public int processedBytes;
11 | public Socket socket;
12 | public AutoResetEvent waitEvent = new AutoResetEvent(false);
13 |
14 | public AsyncStatusObject(Socket sock)
15 | {
16 | this.socket = sock;
17 | }
18 | }
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/puush.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | en-US
11 | false
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/ScreenSelection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using Gma.UserActivityMonitor;
9 |
10 | namespace puush
11 | {
12 |
13 |
14 | public partial class ScreenSelection : Form
15 | {
16 | private const int WM_NCMOUSEMOVE = 0xa0;
17 | private const int WM_NCLBUTTONDOWN = 0xa1;
18 | private const int WM_NCLBUTTONUP = 0xa2;
19 |
20 | private Bitmap b;
21 |
22 | public ScreenSelection()
23 | {
24 | InitializeComponent();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HeaderField.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class HeaderField
6 | {
7 | private string name;
8 | private string theValue;
9 |
10 | public HeaderField(string name, string theValue)
11 | {
12 | this.name = name;
13 | this.theValue = theValue;
14 | }
15 |
16 | public string Name
17 | {
18 | get
19 | {
20 | return this.name;
21 | }
22 | }
23 |
24 | public string Value
25 | {
26 | get
27 | {
28 | return this.theValue;
29 | }
30 | }
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HostInfo.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class HostInfo
6 | {
7 | internal string ipAddress;
8 | private string name;
9 |
10 | public HostInfo(string ipAddress, string name)
11 | {
12 | this.ipAddress = ipAddress;
13 | this.name = name;
14 | }
15 |
16 | public string IPAddress
17 | {
18 | get
19 | {
20 | return this.ipAddress;
21 | }
22 | }
23 |
24 | public string Name
25 | {
26 | get
27 | {
28 | return this.name;
29 | }
30 | }
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpError.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class HttpError : SocketError
6 | {
7 | private string[] responseText;
8 |
9 | public HttpError(string message, int errorCode, string[] responseText) : base(message, errorCode)
10 | {
11 | this.responseText = responseText;
12 | }
13 |
14 | public HttpError(string message, int errorCode, string[] responseText, Exception innerException) : base(message, errorCode, innerException)
15 | {
16 | this.responseText = responseText;
17 | }
18 |
19 | public string[] ResponseText
20 | {
21 | get
22 | {
23 | return this.responseText;
24 | }
25 | }
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/Libraries/NetLib/SocketProgressEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class SocketProgressEventArgs : EventArgs
6 | {
7 | private long bytesProceed;
8 | private long totalBytes;
9 |
10 | public SocketProgressEventArgs(long bytesProceed, long totalBytes)
11 | {
12 | this.bytesProceed = bytesProceed;
13 | this.totalBytes = totalBytes;
14 | }
15 |
16 | public long BytesProceed
17 | {
18 | get
19 | {
20 | return this.bytesProceed;
21 | }
22 | }
23 |
24 | public long TotalBytes
25 | {
26 | get
27 | {
28 | return this.totalBytes;
29 | }
30 | }
31 | }
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/Libraries/NetLib/DataAddedEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 |
6 | public class DataAddedEventArgs : EventArgs
7 | {
8 | private HttpRequestItem item;
9 | private System.IO.Stream stream;
10 |
11 | public DataAddedEventArgs(HttpRequestItem item, System.IO.Stream stream)
12 | {
13 | this.item = item;
14 | this.stream = stream;
15 | }
16 |
17 | public HttpRequestItem Item
18 | {
19 | get
20 | {
21 | return this.item;
22 | }
23 | }
24 |
25 | public System.IO.Stream Stream
26 | {
27 | get
28 | {
29 | return this.stream;
30 | }
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRequestUtils.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 | using System.Net;
6 | using System.Text;
7 |
8 | internal sealed class HttpRequestUtils
9 | {
10 | public static string DownloadUrl(string url)
11 | {
12 | WebResponse response = WebRequest.Create(url).GetResponse();
13 | string str = string.Empty;
14 | try
15 | {
16 | using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8")))
17 | {
18 | return reader.ReadToEnd();
19 | }
20 | }
21 | finally
22 | {
23 | response.Close();
24 | }
25 | }
26 | }
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/puush.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "puush", "puush.csproj", "{DAB92AE6-F7B2-4598-BF99-CB825B579EB3}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|x86 = Debug|x86
9 | Release|x86 = Release|x86
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {DAB92AE6-F7B2-4598-BF99-CB825B579EB3}.Debug|x86.ActiveCfg = Debug|x86
13 | {DAB92AE6-F7B2-4598-BF99-CB825B579EB3}.Debug|x86.Build.0 = Debug|x86
14 | {DAB92AE6-F7B2-4598-BF99-CB825B579EB3}.Release|x86.ActiveCfg = Release|x86
15 | {DAB92AE6-F7B2-4598-BF99-CB825B579EB3}.Release|x86.Build.0 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/Libraries/NetLib/GetDataStreamEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 |
6 | public class GetDataStreamEventArgs : EventArgs
7 | {
8 | private HttpRequestItem item;
9 | private System.IO.Stream stream;
10 |
11 | public GetDataStreamEventArgs(HttpRequestItem item)
12 | {
13 | this.item = item;
14 | this.stream = null;
15 | }
16 |
17 | public HttpRequestItem Item
18 | {
19 | get
20 | {
21 | return this.item;
22 | }
23 | }
24 |
25 | public System.IO.Stream Stream
26 | {
27 | get
28 | {
29 | return this.stream;
30 | }
31 | set
32 | {
33 | this.stream = value;
34 | }
35 | }
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRequestEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class HttpRequestEventArgs : EventArgs
6 | {
7 | private string method;
8 | private string[] requestHeader;
9 | private Uri url;
10 |
11 | public HttpRequestEventArgs(string method, Uri url, string[] requestHeader)
12 | {
13 | this.method = method;
14 | this.url = url;
15 | this.requestHeader = requestHeader;
16 | }
17 |
18 | public string Method
19 | {
20 | get
21 | {
22 | return this.method;
23 | }
24 | }
25 |
26 | public string[] RequestHeader
27 | {
28 | get
29 | {
30 | return this.requestHeader;
31 | }
32 | }
33 |
34 | public Uri Url
35 | {
36 | get
37 | {
38 | return this.url;
39 | }
40 | }
41 | }
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/ToolStripItemThumbnail.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 | using System.Drawing;
6 |
7 | namespace puush
8 | {
9 | class ToolStripItemThumbnail : ToolStripItem
10 | {
11 | Image thumbnail;
12 |
13 | public ToolStripItemThumbnail(Image thumbnail, int width) : base()
14 | {
15 | this.thumbnail = thumbnail;
16 | AutoSize = false;
17 | Width = 170;
18 | Height = thumbnail.Height;
19 | }
20 |
21 | protected override void Dispose(bool disposing)
22 | {
23 | if (thumbnail != null)
24 | {
25 | thumbnail.Dispose();
26 | thumbnail = null;
27 | }
28 |
29 | base.Dispose(disposing);
30 | }
31 |
32 | protected override void OnPaint(PaintEventArgs e)
33 | {
34 | e.Graphics.DrawImage(thumbnail, new Point((Width - thumbnail.Width) / 2,0));
35 | base.OnPaint(e);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Libraries/NetLib/StringStream.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 | using System.Text;
6 |
7 | public class StringStream : MemoryStream
8 | {
9 | public StringStream() : this(string.Empty, new object[0])
10 | {
11 | }
12 |
13 | public StringStream(string text) : this(text, new object[0])
14 | {
15 | }
16 |
17 | public StringStream(string text, params object[] args)
18 | {
19 | StreamWriter writer = new StreamWriter(this, Encoding.Default);
20 | writer.Write(text, args);
21 | writer.Flush();
22 | this.Seek(0L, SeekOrigin.Begin);
23 | }
24 |
25 | public string StringData
26 | {
27 | get
28 | {
29 | long position = this.Position;
30 | this.Seek(0L, SeekOrigin.Begin);
31 | string str = new StreamReader(this, Encoding.Default).ReadToEnd();
32 | this.Seek(position, SeekOrigin.Begin);
33 | return str;
34 | }
35 | }
36 | }
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/Libraries/NetLib/StreamUtils.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 |
6 | public sealed class StreamUtils
7 | {
8 | private StreamUtils()
9 | {
10 | }
11 |
12 | public static long Copy(Stream source, Stream destination, long count)
13 | {
14 | if (count == 0L)
15 | {
16 | source.Position = 0L;
17 | count = source.Length;
18 | }
19 | long num = count;
20 | byte[] buffer = new byte[0xf000];
21 | int length = (int) count;
22 | if (length > buffer.Length)
23 | {
24 | length = buffer.Length;
25 | }
26 | while (count != 0L)
27 | {
28 | int num3 = (int) count;
29 | if (count > length)
30 | {
31 | num3 = length;
32 | }
33 | source.Read(buffer, 0, num3);
34 | destination.Write(buffer, 0, num3);
35 | count -= num3;
36 | }
37 | return num;
38 | }
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/Libraries/NetLib/SocketError.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class SocketError : Exception
6 | {
7 | public const string BatchSizeInvalid = "Invalid Batch Size";
8 | private int errorCode;
9 | public const string InvalidAddress = "Invalid host address";
10 | public const string InvalidPort = "Invalid port number";
11 | public const string NoNetworkStream = "NetworkStream is required";
12 | public const string SocketIsInvalid = "Connection is closed";
13 | public const int SocketIsInvalidCode = 0x2736;
14 | public const string TimeoutOccured = "Timeout error occured";
15 |
16 | public SocketError(string message, int errorCode) : base(message)
17 | {
18 | this.errorCode = errorCode;
19 | }
20 |
21 | public SocketError(string message, int errorCode, Exception exception) : base(message, exception)
22 | {
23 | this.errorCode = errorCode;
24 | }
25 |
26 | public int ErrorCode
27 | {
28 | get
29 | {
30 | return this.errorCode;
31 | }
32 | }
33 | }
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/Libraries/NetLib/Translator.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Text;
5 |
6 | public sealed class Translator
7 | {
8 | private Translator()
9 | {
10 | }
11 |
12 | public static byte[] GetBytes(string text, string charSet)
13 | {
14 | if (!StringUtils.IsEmpty(charSet))
15 | {
16 | try
17 | {
18 | return Encoding.GetEncoding(charSet).GetBytes(text);
19 | }
20 | catch (NotSupportedException)
21 | {
22 | }
23 | catch (ArgumentException)
24 | {
25 | }
26 | }
27 | return Encoding.ASCII.GetBytes(text);
28 | }
29 |
30 | public static string GetString(byte[] bytes, string charSet)
31 | {
32 | if (!StringUtils.IsEmpty(charSet))
33 | {
34 | try
35 | {
36 | return Encoding.GetEncoding(charSet).GetString(bytes);
37 | }
38 | catch
39 | {
40 | }
41 | }
42 | return Encoding.ASCII.GetString(bytes);
43 | }
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpResponseEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class HttpResponseEventArgs : EventArgs
6 | {
7 | private CookieList cookies;
8 | private string method;
9 | private string[] responseHeader;
10 | private Uri url;
11 |
12 | public HttpResponseEventArgs(string method, Uri url, string[] responseHeader, CookieList cookies)
13 | {
14 | this.method = method;
15 | this.url = url;
16 | this.responseHeader = responseHeader;
17 | this.cookies = cookies;
18 | }
19 |
20 | public CookieList Cookies
21 | {
22 | get
23 | {
24 | return this.cookies;
25 | }
26 | }
27 |
28 | public string Method
29 | {
30 | get
31 | {
32 | return this.method;
33 | }
34 | }
35 |
36 | public string[] ResponseHeader
37 | {
38 | get
39 | {
40 | return this.responseHeader;
41 | }
42 | }
43 |
44 | public Uri Url
45 | {
46 | get
47 | {
48 | return this.url;
49 | }
50 | }
51 | }
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/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("puush")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("puush")]
13 | [assembly: AssemblyCopyright("")]
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("4892fef5-1cef-4fc0-9e64-6e048b9d8154")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Libraries/NetLib/BinaryRequestItem.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 |
6 | public class BinaryRequestItem : HttpRequestItem
7 | {
8 | protected internal override void AddData(byte[] data, int index, int length)
9 | {
10 | if (base.Owner != null)
11 | {
12 | if (base.Owner.dataStream == null)
13 | {
14 | GetDataStreamEventArgs e = new GetDataStreamEventArgs(this);
15 | base.Owner.OnGetDataStream(e);
16 | base.Owner.dataStream = e.Stream;
17 | }
18 | if (base.Owner.dataStream != null)
19 | {
20 | base.Owner.dataStream.Write(data, index, length);
21 | }
22 | }
23 | }
24 |
25 | protected internal override void AfterAddData()
26 | {
27 | if ((base.Owner != null) && (base.Owner.dataStream != null))
28 | {
29 | base.Owner.dataStream.Seek(0L, SeekOrigin.Begin);
30 | base.Owner.OnDataAdded(new DataAddedEventArgs(this, base.Owner.dataStream));
31 | }
32 | }
33 |
34 | public override Stream GetData()
35 | {
36 | GetDataStreamEventArgs e = new GetDataStreamEventArgs(this);
37 | if (base.Owner != null)
38 | {
39 | base.Owner.OnGetDataSourceStream(e);
40 | }
41 | if (e.Stream == null)
42 | {
43 | return Stream.Null;
44 | }
45 | e.Stream.Seek(0L, SeekOrigin.Begin);
46 | return e.Stream;
47 | }
48 | }
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpProxySettings.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace osu_common.Libraries.NetLib
4 | {
5 | [TypeConverter(typeof (ExpandableObjectConverter))]
6 | public class HttpProxySettings
7 | {
8 | private AuthenticationType authenticationType;
9 | private string password;
10 | private int port;
11 | private string server;
12 | private string userName;
13 |
14 | public HttpProxySettings()
15 | {
16 | Clear();
17 | }
18 |
19 | [DefaultValue(1)]
20 | public AuthenticationType AuthenticationType
21 | {
22 | get { return authenticationType; }
23 | set { authenticationType = value; }
24 | }
25 |
26 | [DefaultValue("")]
27 | public string Password
28 | {
29 | get { return password; }
30 | set { password = value; }
31 | }
32 |
33 | [DefaultValue(0x1f90)]
34 | public int Port
35 | {
36 | get { return port; }
37 | set { port = value; }
38 | }
39 |
40 | [DefaultValue("")]
41 | public string Server
42 | {
43 | get { return server; }
44 | set { server = value; }
45 | }
46 |
47 | [DefaultValue("")]
48 | public string UserName
49 | {
50 | get { return userName; }
51 | set { userName = value; }
52 | }
53 |
54 | public void Clear()
55 | {
56 | authenticationType = AuthenticationType.AutoDetect;
57 | userName = string.Empty;
58 | password = string.Empty;
59 | server = string.Empty;
60 | port = 0x1f90;
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/TextRequestItem.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.ComponentModel;
5 | using System.IO;
6 | using System.Text;
7 |
8 | public class TextRequestItem : HttpRequestItem
9 | {
10 | private string textData;
11 |
12 | public TextRequestItem()
13 | {
14 | this.textData = string.Empty;
15 | }
16 |
17 | public TextRequestItem(string textData)
18 | {
19 | this.textData = textData;
20 | }
21 |
22 | protected internal override void AddData(byte[] data, int index, int length)
23 | {
24 | this.TextData = this.TextData + Encoding.ASCII.GetString(data, index, length);
25 | }
26 |
27 | protected internal override void AfterAddData()
28 | {
29 | if (base.Owner != null)
30 | {
31 | base.Owner.OnDataAdded(new DataAddedEventArgs(this, new StringStream(this.TextData)));
32 | }
33 | }
34 |
35 | public override Stream GetData()
36 | {
37 | if (!StringUtils.IsEmpty(this.TextData))
38 | {
39 | return new StringStream(this.TextData);
40 | }
41 | return Stream.Null;
42 | }
43 |
44 | [DefaultValue("")]
45 | public string TextData
46 | {
47 | get
48 | {
49 | return this.textData;
50 | }
51 | set
52 | {
53 | if (this.textData != value)
54 | {
55 | this.textData = value;
56 | base.Update();
57 | }
58 | }
59 | }
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/Libraries/NetLib/TcpClientConnection.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Net;
5 | using System.Net.Sockets;
6 |
7 | public class TcpClientConnection : SyncConnection
8 | {
9 | public void Open(IPAddress ip, int port)
10 | {
11 | bool isReadUntilClose = base.IsReadUntilClose;
12 | base.IsReadUntilClose = false;
13 | base.CreateSocket(SocketType.Stream, ProtocolType.Tcp);
14 | base.NetworkStream.Connect(ip, port);
15 | if (base.IsAborted)
16 | {
17 | base.Close(false);
18 | }
19 | else
20 | {
21 | base.active_ = true;
22 | this.DispatchNextAction();
23 | base.NetworkStream.StreamReady();
24 | }
25 | base.IsReadUntilClose = isReadUntilClose;
26 | }
27 |
28 | public void OpenSession()
29 | {
30 | bool isReadUntilClose = base.IsReadUntilClose;
31 | base.IsReadUntilClose = false;
32 | base.NetworkStream.OpenClientSession();
33 | if (base.IsAborted)
34 | {
35 | base.Close(false);
36 | }
37 | else
38 | {
39 | this.DispatchNextAction();
40 | base.NetworkStream.StreamReady();
41 | }
42 | base.IsReadUntilClose = isReadUntilClose;
43 | }
44 |
45 | public IPAddress IP
46 | {
47 | get
48 | {
49 | return base.NetworkStream.IP;
50 | }
51 | }
52 |
53 | public int Port
54 | {
55 | get
56 | {
57 | return base.NetworkStream.Port;
58 | }
59 | }
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/Libraries/Hooking/MouseEventExtArgs.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 |
3 | namespace Gma.UserActivityMonitor
4 | {
5 | ///
6 | /// Provides data for the MouseClickExt and MouseMoveExt events. It also provides a property Handled.
7 | /// Set this property to true to prevent further processing of the event in other applications.
8 | ///
9 | public class MouseEventExtArgs : MouseEventArgs
10 | {
11 | ///
12 | /// Initializes a new instance of the MouseEventArgs class.
13 | ///
14 | /// One of the MouseButtons values indicating which mouse button was pressed.
15 | /// The number of times a mouse button was pressed.
16 | /// The x-coordinate of a mouse click, in pixels.
17 | /// The y-coordinate of a mouse click, in pixels.
18 | /// A signed count of the number of detents the wheel has rotated.
19 | public MouseEventExtArgs(MouseButtons buttons, int clicks, int x, int y, int delta)
20 | : base(buttons, clicks, x, y, delta)
21 | {}
22 |
23 | ///
24 | /// Initializes a new instance of the MouseEventArgs class.
25 | ///
26 | /// An ordinary argument to be extended.
27 | internal MouseEventExtArgs(MouseEventArgs e) : base(e.Button, e.Clicks, e.X, e.Y, e.Delta)
28 | {}
29 |
30 | private bool m_Handled;
31 |
32 | ///
33 | /// Set this property to true inside your event handler to prevent further processing of the event in other applications.
34 | ///
35 | public bool Handled
36 | {
37 | get { return m_Handled; }
38 | set { m_Handled = value; }
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Libraries/NetLib/DataNetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading;
4 |
5 | namespace osu_common.Libraries.NetLib
6 | {
7 | ///
8 | /// Downloads a file from the internet to a specified location
9 | ///
10 | public class DataNetRequest : NetRequest
11 | {
12 | public DataNetRequest(string _url)
13 | : base(_url)
14 | {
15 | }
16 |
17 | public event RequestStartHandler onStart;
18 | public event RequestUpdateHandler onUpdate;
19 | public event RequestCompleteHandler onFinish;
20 |
21 |
22 | public override void Perform()
23 | {
24 | try
25 | {
26 | //inform subscribers that we have started
27 | if (onStart != null)
28 | onStart();
29 |
30 |
31 | using (Stream dataStream = new MemoryStream())
32 | {
33 | using (Http h = new Http())
34 | h.Get(m_url, dataStream);
35 |
36 | dataStream.Position = 0;
37 | byte[] output = new byte[dataStream.Length];
38 | dataStream.Read(output, 0, (int)dataStream.Length);
39 |
40 | //inform subscribers that we have finished
41 | if (onFinish != null)
42 | onFinish(output, null);
43 | }
44 | }
45 | catch (ThreadAbortException)
46 | { }
47 | }
48 |
49 | public override bool Valid()
50 | {
51 | return true;
52 | }
53 |
54 | public override void OnException(Exception e)
55 | {
56 | if (onFinish != null)
57 | onFinish(null, e);
58 | }
59 |
60 | #region Nested type: RequestCompleteHandler
61 |
62 | public delegate void RequestCompleteHandler(byte[] data, Exception e);
63 |
64 | #endregion
65 | }
66 | }
--------------------------------------------------------------------------------
/UpdateAvailableDialog.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using System.Runtime.InteropServices;
9 | using osu_common.Helpers;
10 |
11 | namespace puush
12 | {
13 | public partial class UpdateAvailableDialog : pForm
14 | {
15 | private const int FEATURE_DISABLE_NAVIGATION_SOUNDS = 21;
16 | private const int SET_FEATURE_ON_THREAD = 0x00000001;
17 | private const int SET_FEATURE_ON_PROCESS = 0x00000002;
18 | private const int SET_FEATURE_IN_REGISTRY = 0x00000004;
19 | private const int SET_FEATURE_ON_THREAD_LOCALMACHINE = 0x00000008;
20 | private const int SET_FEATURE_ON_THREAD_INTRANET = 0x00000010;
21 | private const int SET_FEATURE_ON_THREAD_TRUSTED = 0x00000020;
22 | private const int SET_FEATURE_ON_THREAD_INTERNET = 0x00000040;
23 | private const int SET_FEATURE_ON_THREAD_RESTRICTED = 0x00000080;
24 |
25 | [DllImport("urlmon.dll")]
26 | [PreserveSig]
27 | [return: MarshalAs(UnmanagedType.Error)]
28 | static extern int CoInternetSetFeatureEnabled(int FeatureEntry, [MarshalAs(UnmanagedType.U4)] int dwFlags, bool fEnable);
29 |
30 | public UpdateAvailableDialog()
31 | {
32 | InitializeComponent();
33 | CoInternetSetFeatureEnabled(FEATURE_DISABLE_NAVIGATION_SOUNDS, SET_FEATURE_ON_PROCESS, true);
34 | }
35 |
36 | protected override void OnShown(EventArgs e)
37 | {
38 | webBrowser1.Url = new Uri(puush.getPuushUrl("changelog"));
39 |
40 | Show();
41 | Focus();
42 | BringToFront();
43 | TopMost = true;
44 | TopMost = false;
45 |
46 | base.OnShown(e);
47 | }
48 |
49 | private void buttonDownload_Click(object sender, EventArgs e)
50 | {
51 | DialogResult = DialogResult.OK;
52 | Close();
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Libraries/TopMostMessageBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 |
6 | namespace puush.Libraries
7 | {
8 | static public class TopMostMessageBox
9 | {
10 | static public DialogResult Show(string message)
11 | {
12 | return Show(message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
13 | }
14 |
15 | static public DialogResult Show(string message, string title)
16 | {
17 | return Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
18 | }
19 |
20 | static public DialogResult Show(string message, string title,
21 | MessageBoxButtons buttons, MessageBoxIcon icon)
22 | {
23 | // Create a host form that is a TopMost window which will be the
24 |
25 | // parent of the MessageBox.
26 |
27 | Form topmostForm = new Form();
28 | // We do not want anyone to see this window so position it off the
29 |
30 | // visible screen and make it as small as possible
31 |
32 | topmostForm.ShowInTaskbar = false;
33 |
34 | topmostForm.Size = new System.Drawing.Size(1, 1);
35 | topmostForm.StartPosition = FormStartPosition.Manual;
36 | System.Drawing.Rectangle rect = SystemInformation.VirtualScreen;
37 | topmostForm.Location = new System.Drawing.Point(rect.Bottom + 10,
38 | rect.Right + 10);
39 | topmostForm.Show();
40 | // Make this form the active form and make it TopMost
41 |
42 | topmostForm.Focus();
43 | topmostForm.BringToFront();
44 | topmostForm.TopMost = true;
45 | // Finally show the MessageBox with the form just created as its owner
46 |
47 | DialogResult result = MessageBox.Show(topmostForm, message, title,
48 | buttons,icon);
49 | topmostForm.Dispose(); // clean it up all the way
50 |
51 |
52 | return result;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HostList.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Collections;
5 | using System.Globalization;
6 | using System.Reflection;
7 |
8 | public class HostList : ICollection, IEnumerable
9 | {
10 | private ArrayList list = new ArrayList();
11 |
12 | protected internal void Add(HostInfo item)
13 | {
14 | this.list.Add(item);
15 | }
16 |
17 | protected internal void Clear()
18 | {
19 | this.list.Clear();
20 | }
21 |
22 | public void CopyTo(Array array, int index)
23 | {
24 | this.list.CopyTo(array, index);
25 | }
26 |
27 | public IEnumerator GetEnumerator()
28 | {
29 | return this.list.GetEnumerator();
30 | }
31 |
32 | protected internal void Insert(int index, HostInfo item)
33 | {
34 | this.list.Insert(index, item);
35 | }
36 |
37 | public int Count
38 | {
39 | get
40 | {
41 | return this.list.Count;
42 | }
43 | }
44 |
45 | public bool IsSynchronized
46 | {
47 | get
48 | {
49 | return this.list.IsSynchronized;
50 | }
51 | }
52 |
53 | public HostInfo this[int index]
54 | {
55 | get
56 | {
57 | return (HostInfo) this.list[index];
58 | }
59 | }
60 |
61 | public HostInfo this[string name]
62 | {
63 | get
64 | {
65 | foreach (HostInfo info in this)
66 | {
67 | if (string.Compare(info.Name, name, true, CultureInfo.InvariantCulture) == 0)
68 | {
69 | return info;
70 | }
71 | }
72 | return null;
73 | }
74 | }
75 |
76 | public object SyncRoot
77 | {
78 | get
79 | {
80 | return this.list.SyncRoot;
81 | }
82 | }
83 | }
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/Libraries/NetLib/Utils.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.IO;
5 |
6 | public sealed class Utils
7 | {
8 | private static int TwoDigitYearCenturyWindow = 50;
9 |
10 | private Utils()
11 | {
12 | }
13 |
14 | public static string ExtractFileName(string path)
15 | {
16 | string fileName = Path.GetFileName(path);
17 | if (fileName == null)
18 | {
19 | return string.Empty;
20 | }
21 | return fileName;
22 | }
23 |
24 | public static int GetCorrectY2k(int year)
25 | {
26 | if (year >= 100)
27 | {
28 | return year;
29 | }
30 | int num = year;
31 | if (TwoDigitYearCenturyWindow > 0)
32 | {
33 | if (num > TwoDigitYearCenturyWindow)
34 | {
35 | return (num + (((DateTime.Today.Year / 100) - 1) * 100));
36 | }
37 | return (num + ((DateTime.Today.Year / 100) * 100));
38 | }
39 | return (num + ((DateTime.Today.Year / 100) * 100));
40 | }
41 |
42 | public static int IndexOfArray(byte[] theValue, byte[] buffer, int startPos)
43 | {
44 | return IndexOfArray(theValue, buffer, startPos, buffer.Length);
45 | }
46 |
47 | public static int IndexOfArray(byte[] theValue, byte[] buffer, int startPos, int length)
48 | {
49 | int index = 0;
50 | int num2 = theValue.Length;
51 | for (int i = startPos; i < length; i++)
52 | {
53 | if (buffer[i] == theValue[index])
54 | {
55 | index++;
56 | }
57 | else
58 | {
59 | index = 0;
60 | continue;
61 | }
62 | if (index == num2)
63 | {
64 | return ((i - num2) + 1);
65 | }
66 | }
67 | return -1;
68 | }
69 | }
70 | }
71 |
72 |
--------------------------------------------------------------------------------
/Libraries/NetLib/NetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace osu_common.Libraries.NetLib
5 | {
6 | public class AbortedException : Exception
7 | {
8 | public AbortedException() : base("Request has been aborted")
9 | {
10 |
11 | }
12 |
13 | }
14 |
15 | ///
16 | /// base type for all net requests. Pass this object to a Netmanager
17 | /// which calls Perform in its thread pool.
18 | ///
19 | public abstract class NetRequest
20 | {
21 | protected string m_url;
22 | internal Thread thread;
23 | internal bool AbortRequested;
24 | internal bool IsQueued;
25 |
26 | public NetRequest(string _url)
27 | {
28 | m_url = _url;
29 | }
30 |
31 | ///
32 | /// Abstract method, this is called by the NetManager's thread pool
33 | ///
34 | public abstract void Perform();
35 |
36 | public virtual void Abort()
37 | {
38 | if (IsQueued)
39 | {
40 | AbortRequested = true;
41 | return;
42 | }
43 |
44 | if (thread != null && thread.IsAlive) thread.Abort();
45 | }
46 |
47 | ///
48 | /// Abstract method, this is called before the request is added to the
49 | /// thread pool.
50 | /// returns true if the request validates
51 | ///
52 | public abstract bool Valid();
53 |
54 |
55 | ///
56 | /// Called if there was an exception performing the request
57 | ///
58 | /// the exception that was thrown
59 | public abstract void OnException(Exception e);
60 |
61 | #region Nested type: RequestStartHandler
62 |
63 | public delegate void RequestStartHandler();
64 |
65 | #endregion
66 |
67 | #region Nested type: RequestUpdateHandler
68 |
69 | public delegate void RequestUpdateHandler(object sender, long current, long total);
70 |
71 | #endregion
72 | }
73 | }
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/Core/IScanFilter.cs:
--------------------------------------------------------------------------------
1 | // IScanFilter.cs
2 | //
3 | // Copyright 2006 John Reilly
4 | //
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (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, write to the Free Software
17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 | //
19 | // Linking this library statically or dynamically with other modules is
20 | // making a combined work based on this library. Thus, the terms and
21 | // conditions of the GNU General Public License cover the whole
22 | // combination.
23 | //
24 | // As a special exception, the copyright holders of this library give you
25 | // permission to link this library with independent modules to produce an
26 | // executable, regardless of the license terms of these independent
27 | // modules, and to copy and distribute the resulting executable under
28 | // terms of your choice, provided that you also meet, for each linked
29 | // independent module, the terms and conditions of the license of that
30 | // module. An independent module is a module which is not derived from
31 | // or based on this library. If you modify this library, you may extend
32 | // this exception to your version of the library, but you are not
33 | // obligated to do so. If you do not wish to do so, delete this
34 | // exception statement from your version.
35 |
36 | using System;
37 |
38 | namespace ICSharpCode.SharpZipLib.Core
39 | {
40 | ///
41 | /// Scanning filters support filtering of names.
42 | ///
43 | public interface IScanFilter
44 | {
45 | ///
46 | /// Test a name to see if it 'matches' the filter.
47 | ///
48 | /// The name to test.
49 | /// Returns true if the name matches the filter, false if it does not match.
50 | bool IsMatch(string name);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/ScreenSelection.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace puush
2 | {
3 | partial class ScreenSelection
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.SuspendLayout();
32 | //
33 | // ScreenSelection
34 | //
35 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
36 | this.AutoValidate = System.Windows.Forms.AutoValidate.Disable;
37 | this.BackColor = System.Drawing.Color.White;
38 | this.CausesValidation = false;
39 | this.ClientSize = new System.Drawing.Size(8, 8);
40 | this.ControlBox = false;
41 | this.Cursor = System.Windows.Forms.Cursors.Cross;
42 | this.ForeColor = System.Drawing.SystemColors.ControlLightLight;
43 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
44 | this.Location = new System.Drawing.Point(-10000, -10000);
45 | this.MaximizeBox = false;
46 | this.MinimizeBox = false;
47 | this.Name = "ScreenSelection";
48 | this.Opacity = 0.2D;
49 | this.ShowIcon = false;
50 | this.ShowInTaskbar = false;
51 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
52 | this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
53 | this.TopMost = true;
54 | this.ResumeLayout(false);
55 |
56 | }
57 |
58 | #endregion
59 |
60 |
61 |
62 |
63 | }
64 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRedirectEventArgs.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class HttpRedirectEventArgs : EventArgs
6 | {
7 | private bool canRedirect;
8 | private bool handled;
9 | private string method;
10 | private string[] requestHeader;
11 | private HttpResponseHeader responseHeader;
12 | private string[] responseText;
13 | private int statusCode;
14 |
15 | public HttpRedirectEventArgs(string[] requestHeader, int statusCode, HttpResponseHeader responseHeader, string[] responseText, string method, bool canRedirect, bool handled)
16 | {
17 | this.requestHeader = requestHeader;
18 | this.statusCode = statusCode;
19 | this.responseHeader = responseHeader;
20 | this.responseText = responseText;
21 | this.method = method;
22 | this.canRedirect = canRedirect;
23 | this.handled = handled;
24 | }
25 |
26 | public bool CanRedirect
27 | {
28 | get
29 | {
30 | return this.canRedirect;
31 | }
32 | set
33 | {
34 | this.canRedirect = value;
35 | }
36 | }
37 |
38 | public bool Handled
39 | {
40 | get
41 | {
42 | return this.handled;
43 | }
44 | set
45 | {
46 | this.handled = value;
47 | }
48 | }
49 |
50 | public string Method
51 | {
52 | get
53 | {
54 | return this.method;
55 | }
56 | set
57 | {
58 | this.method = value;
59 | }
60 | }
61 |
62 | public string[] RequestHeader
63 | {
64 | get
65 | {
66 | return this.requestHeader;
67 | }
68 | }
69 |
70 | public HttpResponseHeader ResponseHeader
71 | {
72 | get
73 | {
74 | return this.responseHeader;
75 | }
76 | }
77 |
78 | public string[] ResponseText
79 | {
80 | get
81 | {
82 | return this.responseText;
83 | }
84 | }
85 |
86 | public int StatusCode
87 | {
88 | get
89 | {
90 | return this.statusCode;
91 | }
92 | }
93 | }
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/Libraries/NetLib/CookieItem.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 |
5 | public class CookieItem
6 | {
7 | private string cookieData;
8 | private string domain;
9 | private string expires;
10 | private string name;
11 | private string path;
12 | private bool secure;
13 | private string theValue;
14 |
15 | public CookieItem()
16 | {
17 | }
18 |
19 | public CookieItem(string name, string theValue)
20 | {
21 | this.name = name;
22 | this.theValue = theValue;
23 | }
24 |
25 | public string CookieData
26 | {
27 | get
28 | {
29 | return this.cookieData;
30 | }
31 | set
32 | {
33 | this.cookieData = value;
34 | }
35 | }
36 |
37 | public string Domain
38 | {
39 | get
40 | {
41 | return this.domain;
42 | }
43 | set
44 | {
45 | this.domain = value;
46 | }
47 | }
48 |
49 | public string Expires
50 | {
51 | get
52 | {
53 | return this.expires;
54 | }
55 | set
56 | {
57 | this.expires = value;
58 | }
59 | }
60 |
61 | public string Name
62 | {
63 | get
64 | {
65 | return this.name;
66 | }
67 | set
68 | {
69 | this.name = value;
70 | }
71 | }
72 |
73 | public string Path
74 | {
75 | get
76 | {
77 | return this.path;
78 | }
79 | set
80 | {
81 | this.path = value;
82 | }
83 | }
84 |
85 | public bool Secure
86 | {
87 | get
88 | {
89 | return this.secure;
90 | }
91 | set
92 | {
93 | this.secure = value;
94 | }
95 | }
96 |
97 | public string Value
98 | {
99 | get
100 | {
101 | return this.theValue;
102 | }
103 | set
104 | {
105 | this.theValue = value;
106 | }
107 | }
108 | }
109 | }
110 |
111 |
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/Zip/Compression/DeflaterPending.cs:
--------------------------------------------------------------------------------
1 | // DeflaterPending.cs
2 | //
3 | // Copyright (C) 2001 Mike Krueger
4 | // Copyright (C) 2004 John Reilly
5 | //
6 | // This file was translated from java, it was part of the GNU Classpath
7 | // Copyright (C) 2001 Free Software Foundation, Inc.
8 | //
9 | // This program is free software; you can redistribute it and/or
10 | // modify it under the terms of the GNU General Public License
11 | // as published by the Free Software Foundation; either version 2
12 | // of the License, or (at your option) any later version.
13 | //
14 | // This program is distributed in the hope that it will be useful,
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 | // GNU General Public License for more details.
18 | //
19 | // You should have received a copy of the GNU General Public License
20 | // along with this program; if not, write to the Free Software
21 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 | //
23 | // Linking this library statically or dynamically with other modules is
24 | // making a combined work based on this library. Thus, the terms and
25 | // conditions of the GNU General Public License cover the whole
26 | // combination.
27 | //
28 | // As a special exception, the copyright holders of this library give you
29 | // permission to link this library with independent modules to produce an
30 | // executable, regardless of the license terms of these independent
31 | // modules, and to copy and distribute the resulting executable under
32 | // terms of your choice, provided that you also meet, for each linked
33 | // independent module, the terms and conditions of the license of that
34 | // module. An independent module is a module which is not derived from
35 | // or based on this library. If you modify this library, you may extend
36 | // this exception to your version of the library, but you are not
37 | // obligated to do so. If you do not wish to do so, delete this
38 | // exception statement from your version.
39 |
40 | namespace ICSharpCode.SharpZipLib.Zip.Compression
41 | {
42 |
43 | ///
44 | /// This class stores the pending output of the Deflater.
45 | ///
46 | /// author of the original java version : Jochen Hoenicke
47 | ///
48 | public class DeflaterPending : PendingBuffer
49 | {
50 | ///
51 | /// Construct instance with default buffer size
52 | ///
53 | public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE)
54 | {
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Libraries/pForm.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 | using System.Threading;
5 |
6 | namespace osu_common.Helpers
7 | {
8 | public class pForm : Form
9 | {
10 | protected override void OnLoad(EventArgs e)
11 | {
12 | FixFonts();
13 |
14 | base.OnLoad(e);
15 | }
16 |
17 | private void FixFonts()
18 | {
19 | Font newFont;
20 |
21 | AutoScaleMode = AutoScaleMode.None;
22 |
23 |
24 |
25 | foreach (Control c in Controls)
26 | c.Font = Font;
27 | }
28 |
29 | public override Font Font
30 | {
31 | get
32 | {
33 | if (Environment.OSVersion.Version.Major < 6)
34 | {
35 | //Windows 2000 (5.0), Windows XP (5.1), Windows Server 2003 and XP Pro x64 Edtion v2003 (5.2)
36 | return SystemFonts.DialogFont; //Tahoma hopefully
37 | }
38 | else
39 | {
40 | //Vista and above
41 | return SystemFonts.MessageBoxFont; //should be SegoiUI
42 | }
43 | }
44 | set
45 | {
46 | base.Font = value;
47 | }
48 | }
49 |
50 | public void Invoke(MethodInvoker moo)
51 | {
52 | Invoke(moo, false);
53 | }
54 |
55 | public void Invoke(MethodInvoker moo, bool force)
56 | {
57 | try
58 | {
59 | if (InvokeRequired)
60 | {
61 | if (!base.IsHandleCreated)
62 | {
63 | Thread.Sleep(3000);
64 | if (!base.IsHandleCreated)
65 | return;
66 | }
67 |
68 | if (Disposing || IsDisposed)
69 | return;
70 |
71 | int tryCount = 5;
72 | while (tryCount-- > 0)
73 | {
74 | if (IsHandleCreated)
75 | {
76 | base.Invoke(moo);
77 | break;
78 | }
79 | else
80 | Thread.Sleep(600);
81 | }
82 | }
83 | else
84 | moo();
85 | }
86 | catch
87 | { }
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/IPC.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Runtime.Remoting.Channels;
5 | using System.Runtime.Remoting.Channels.Ipc;
6 | using System.Runtime.Remoting;
7 |
8 | namespace puush
9 | {
10 | public class IpcLoader : MarshalByRefObject
11 | {
12 | public void puush(string filename)
13 | {
14 | FileUpload.Upload(filename);
15 | }
16 | }
17 |
18 | internal static class IPC
19 | {
20 | internal static IpcChannel Channel;
21 | internal static void AcceptConnections()
22 | {
23 | bool accepted = acceptConnections();
24 |
25 | if (accepted)
26 | return;
27 |
28 | //kill other instances?
29 | return;
30 | }
31 |
32 | internal static void Unregister()
33 | {
34 | if (Channel != null)
35 | ChannelServices.UnregisterChannel(Channel);
36 | }
37 |
38 | private static bool killOtherOsu()
39 | {
40 | try
41 | {
42 | IpcChannel ipcCh = new IpcChannel("puush-incoming");
43 | ChannelServices.RegisterChannel(ipcCh, false);
44 |
45 | IpcLoader otherOsu = (IpcLoader)Activator.GetObject(typeof(IpcLoader), "ipc://puush/puush");
46 |
47 | ChannelServices.UnregisterChannel(ipcCh);
48 |
49 | return true;
50 | }
51 | catch { }
52 |
53 | return false;
54 | }
55 |
56 | private static bool acceptConnections()
57 | {
58 | try
59 | {
60 | Channel = new IpcChannel("puush");
61 |
62 | ChannelServices.RegisterChannel(Channel, false);
63 | RemotingConfiguration.RegisterWellKnownServiceType(typeof(IpcLoader), "puush", WellKnownObjectMode.Singleton);
64 |
65 | return true;
66 | }
67 | catch
68 | {
69 | Channel = null;
70 | }
71 |
72 | return false;
73 | }
74 |
75 | internal static void LoadFile(string file)
76 | {
77 | IpcChannel ipcCh = new IpcChannel("puush-incoming");
78 | ChannelServices.RegisterChannel(ipcCh, false);
79 |
80 | IpcLoader obj =
81 | (IpcLoader)Activator.GetObject
82 | (typeof(IpcLoader), "ipc://puush/puush");
83 | obj.puush(file);
84 |
85 | ChannelServices.UnregisterChannel(ipcCh);
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/Core/INameTransform.cs:
--------------------------------------------------------------------------------
1 | // INameTransform.cs
2 | //
3 | // Copyright 2005 John Reilly
4 | //
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (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, write to the Free Software
17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 | //
19 | // Linking this library statically or dynamically with other modules is
20 | // making a combined work based on this library. Thus, the terms and
21 | // conditions of the GNU General Public License cover the whole
22 | // combination.
23 | //
24 | // As a special exception, the copyright holders of this library give you
25 | // permission to link this library with independent modules to produce an
26 | // executable, regardless of the license terms of these independent
27 | // modules, and to copy and distribute the resulting executable under
28 | // terms of your choice, provided that you also meet, for each linked
29 | // independent module, the terms and conditions of the license of that
30 | // module. An independent module is a module which is not derived from
31 | // or based on this library. If you modify this library, you may extend
32 | // this exception to your version of the library, but you are not
33 | // obligated to do so. If you do not wish to do so, delete this
34 | // exception statement from your version.
35 |
36 | namespace ICSharpCode.SharpZipLib.Core
37 | {
38 | ///
39 | /// INameTransform defines how file system names are transformed for use with archives.
40 | ///
41 | public interface INameTransform
42 | {
43 | ///
44 | /// Given a file name determine the transformed value.
45 | ///
46 | /// The name to transform.
47 | /// The transformed file name.
48 | string TransformFile(string name);
49 |
50 | ///
51 | /// Given a directory name determine the transformed value.
52 | ///
53 | /// The name to transform.
54 | /// The transformed directory name
55 | string TransformDirectory(string name);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Libraries/NetLib/StringNetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Reflection;
3 | using System.Text;
4 |
5 | namespace osu_common.Libraries.NetLib
6 | {
7 | ///
8 | /// request string peforms a web request on a url and returns back the
9 | /// result string.
10 | ///
11 | public class StringNetRequest : NetRequest
12 | {
13 | public StringNetRequest(string _url)
14 | : base(_url)
15 | {
16 | }
17 |
18 | public event RequestStartHandler onStart;
19 | public event RequestUpdateHandler onUpdate;
20 | public event RequestCompleteHandler onFinish;
21 |
22 | public override void Perform()
23 | {
24 | BlockingPerform();
25 | }
26 |
27 | public string BlockingPerform()
28 | {
29 | //inform subscribers that we have started
30 | if (onStart != null)
31 | {
32 | onStart();
33 | }
34 |
35 | Http h = new Http();
36 | h.AllowCaching = false;
37 | string[] result = h.Get(m_url);
38 | h.Close();
39 |
40 |
41 | StringBuilder sb = new StringBuilder();
42 | int l = result.Length;
43 | for (int i = 0; i < l; i++)
44 | sb.Append((i > 0 ? "\n" : "") + result[i]);
45 |
46 | string str = sb.ToString();
47 | //inform subscribers that we have finished
48 | if (onFinish != null)
49 | {
50 | try
51 | {
52 | onFinish(str,null);
53 | }
54 | catch { }
55 | }
56 |
57 | return str;
58 | }
59 |
60 |
61 | public override bool Valid()
62 | {
63 | //see if we have any subscribers to onFinish
64 | if (onFinish.GetInvocationList().Length == 0)
65 | {
66 | #if DEBUG
67 | Console.WriteLine("no subscribers to this StringNetRequest complete event");
68 | #endif
69 | return false;
70 | }
71 |
72 | //all string requests are valid, as long as the address formats
73 | //to a correct URI
74 | //TODO: regex checking of m_url
75 | return true;
76 | }
77 |
78 | public override void OnException(Exception e)
79 | {
80 | if (onFinish != null)
81 | onFinish(null, e);
82 | }
83 |
84 | #region Nested type: RequestCompleteHandler
85 |
86 | public delegate void RequestCompleteHandler(string _result, Exception e);
87 |
88 | #endregion
89 | }
90 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/FormFieldRequestItem.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.ComponentModel;
5 | using System.IO;
6 | using System.Text;
7 |
8 | public class FormFieldRequestItem : HttpRequestItem
9 | {
10 | private string fieldName;
11 | private string fieldValue;
12 |
13 | public FormFieldRequestItem()
14 | {
15 | this.fieldName = string.Empty;
16 | this.fieldValue = string.Empty;
17 | }
18 |
19 | public FormFieldRequestItem(string fieldName, string fieldValue)
20 | {
21 | this.fieldName = fieldName;
22 | this.fieldValue = fieldValue;
23 | }
24 |
25 | protected internal override void AddData(byte[] data, int index, int length)
26 | {
27 | this.FieldValue = this.FieldValue + Encoding.ASCII.GetString(data, index, length);
28 | }
29 |
30 | protected internal override void AfterAddData()
31 | {
32 | if (base.Owner != null)
33 | {
34 | base.Owner.OnDataAdded(new DataAddedEventArgs(this, new StringStream(this.FieldValue)));
35 | }
36 | }
37 |
38 | public override Stream GetData()
39 | {
40 | return new StringStream(this.GetRequest());
41 | }
42 |
43 | private string GetRequest()
44 | {
45 | if (base.Owner != null)
46 | {
47 | if (base.Owner.IsMultiPart())
48 | {
49 | return string.Format("Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}", base.GetCanonicalizedValue(this.FieldName), base.GetCanonicalizedValue(this.FieldValue));
50 | }
51 | if (base.Owner.IsForm())
52 | {
53 | return string.Format("{0}={1}", base.GetCanonicalizedValue(this.FieldName), base.GetCanonicalizedValue(this.FieldValue));
54 | }
55 | }
56 | return string.Empty;
57 | }
58 |
59 | [DefaultValue("")]
60 | public string FieldName
61 | {
62 | get
63 | {
64 | return this.fieldName;
65 | }
66 | set
67 | {
68 | if (this.fieldName != value)
69 | {
70 | this.fieldName = value;
71 | base.Update();
72 | }
73 | }
74 | }
75 |
76 | [DefaultValue("")]
77 | public string FieldValue
78 | {
79 | get
80 | {
81 | return this.fieldValue;
82 | }
83 | set
84 | {
85 | if (this.fieldValue != value)
86 | {
87 | this.fieldValue = value;
88 | base.Update();
89 | }
90 | }
91 | }
92 | }
93 | }
94 |
95 |
--------------------------------------------------------------------------------
/Settings.BindingCapture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using osu_common.Libraries.NetLib;
9 | using System.Diagnostics;
10 | using osu_common.Helpers;
11 | using Microsoft.Win32;
12 | using Gma.UserActivityMonitor;
13 |
14 | namespace puush
15 | {
16 | public partial class Settings : pForm
17 | {
18 | internal static bool IsKeyCapturing;
19 |
20 | Button keyCapturingButton;
21 | private KeyBinding keyCapturingBinding;
22 | private List capturedKeys;
23 |
24 | private void StartKeyCapture(Button button, KeyBinding keyBinding)
25 | {
26 | if (IsKeyCapturing)
27 | EndKeyCapture();
28 |
29 | IsKeyCapturing = true;
30 |
31 | button.Text = "Press some keys...";
32 | button.ForeColor = Color.Blue;
33 |
34 | keyCapturingButton = button;
35 | keyCapturingBinding = keyBinding;
36 |
37 | HookManager.KeyDown += new KeyEventHandler(HookManager_KeyDown);
38 |
39 | capturedKeys = new List();
40 |
41 | }
42 |
43 | void HookManager_KeyDown(object sender, KeyEventArgs e)
44 | {
45 | if (e.KeyCode == Keys.Escape)
46 | {
47 | EndKeyCapture();
48 | return;
49 | }
50 |
51 | if (capturedKeys.Contains(e.KeyCode))
52 | return;
53 |
54 | capturedKeys.Add(e.KeyCode);
55 |
56 | Invoke(delegate { keyCapturingButton.Text = BindingManager.GetStringRepresentationFor(capturedKeys); });
57 |
58 | e.Handled = true;
59 |
60 | switch (e.KeyCode)
61 | {
62 | case Keys.LShiftKey:
63 | case Keys.RShiftKey:
64 | case Keys.LControlKey:
65 | case Keys.RControlKey:
66 | case Keys.LMenu:
67 | case Keys.RMenu:
68 | case Keys.LWin:
69 | case Keys.RWin:
70 | return;
71 | default:
72 | EndKeyCapture();
73 | break;
74 | }
75 | }
76 |
77 | private void EndKeyCapture()
78 | {
79 | if (!IsKeyCapturing) return;
80 |
81 | Invoke(delegate { keyCapturingButton.ForeColor = Color.Black; });
82 |
83 | BindingManager.SetBindingFor(keyCapturingBinding, capturedKeys);
84 | keyCapturingButton.Text = BindingManager.GetStringRepresentationFor(keyCapturingBinding);
85 |
86 | keyCapturingButton = null;
87 | IsKeyCapturing = false;
88 |
89 | HookManager.KeyDown -= new KeyEventHandler(HookManager_KeyDown);
90 | }
91 | }
92 |
93 | }
--------------------------------------------------------------------------------
/GlobalHotKey.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Runtime.InteropServices;
4 | using System.Threading;
5 | using puush;
6 |
7 | /// This class allows you to manage a hotkey
8 | public class GlobalHotKey : IDisposable
9 | {
10 | [DllImport("user32", SetLastError = true)]
11 | [return: MarshalAs(UnmanagedType.Bool)]
12 | public static extern bool RegisterHotKey(IntPtr hwnd, int id, uint fsModifiers, uint vk);
13 | [DllImport("user32", SetLastError = true)]
14 | public static extern int UnregisterHotKey(IntPtr hwnd, int id);
15 | [DllImport("kernel32", SetLastError = true)]
16 | public static extern short GlobalAddAtom(string lpString);
17 | [DllImport("kernel32", SetLastError = true)]
18 | public static extern short GlobalDeleteAtom(short nAtom);
19 |
20 | public const int MOD_ALT = 1;
21 | public const int MOD_CONTROL = 2;
22 | public const int MOD_SHIFT = 4;
23 | public const int MOD_WIN = 8;
24 |
25 | public const int WM_HOTKEY = 0x312;
26 |
27 | int hotkey, modifiers;
28 |
29 | public GlobalHotKey(int hotkey, int modifiers)
30 | {
31 | Handle = MainForm.Instance.Handle;
32 | this.hotkey = hotkey;
33 | this.modifiers = modifiers;
34 | }
35 |
36 | /// Handle of the current process
37 | public IntPtr Handle;
38 |
39 | /// The ID for the hotkey
40 | public short id { get; private set; }
41 |
42 | /// Register the hotkey. Re-registers if already registered.
43 | public void Register()
44 | {
45 | UnregisterGlobalHotKey();
46 |
47 | try
48 | {
49 | // use the GlobalAddAtom API to get a unique ID (as suggested by MSDN)
50 | string atomName = Thread.CurrentThread.ManagedThreadId.ToString("X8") + "puush" + hotkey + modifiers;
51 | id = GlobalAddAtom(atomName);
52 | if (id == 0)
53 | throw new Exception("Unable to generate unique hotkey ID. Error: " + Marshal.GetLastWin32Error().ToString());
54 |
55 | // register the hotkey, throw if any error
56 | if (!RegisterHotKey(Handle, id, (uint)modifiers, (uint)hotkey))
57 | throw new Exception("Unable to register hotkey. Error: " + Marshal.GetLastWin32Error().ToString());
58 |
59 | }
60 | catch (Exception ex)
61 | {
62 | // clean up if hotkey registration failed
63 | Dispose();
64 | Console.WriteLine(ex);
65 | }
66 | }
67 |
68 | /// Unregister the hotkey
69 | public void UnregisterGlobalHotKey()
70 | {
71 | if (this.id != 0)
72 | {
73 | UnregisterHotKey(Handle, id);
74 | // clean up the atom list
75 | GlobalDeleteAtom(id);
76 | id = 0;
77 | }
78 | }
79 |
80 | public void Dispose()
81 | {
82 | UnregisterGlobalHotKey();
83 | }
84 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/FormDataNetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace osu_common.Libraries.NetLib
5 | {
6 | ///
7 | /// POSTs a byte buffer to a url
8 | ///
9 | public class FormDataNetRequest : NetRequest
10 | {
11 | private readonly byte[] m_buffer;
12 | private readonly string m_filename;
13 | private readonly string m_labelname;
14 | private Http http;
15 |
16 | public FormDataNetRequest(string _url)
17 | : base(_url)
18 | {
19 | BufferSize = 8192; //default buffer size is 8kb
20 |
21 | http = new Http();
22 | request = new HttpRequest();
23 | http.Request = request;
24 | }
25 |
26 | public void AddField(string key, string val)
27 | {
28 | request.Items.AddFormField(key,val);
29 | }
30 |
31 | public int BufferSize { get; set; }
32 |
33 | public event RequestStartHandler onStart;
34 | public event RequestUpdateHandler onUpdate;
35 | public event RequestCompleteHandler onFinish;
36 | public HttpRequest request;
37 |
38 | public override void Perform()
39 | {
40 | BlockingPerform();
41 | }
42 |
43 | public byte[] BlockingPerform()
44 | {
45 | //inform subscribers that we have started
46 | if (onStart != null)
47 | onStart();
48 |
49 | MemoryStream res = new MemoryStream();
50 | try
51 | {
52 |
53 | http.SendProgress += http_SendProgress;
54 | http.Post(m_url, request, res);
55 | http.SendProgress -= http_SendProgress;
56 | }
57 | catch
58 | {
59 | }
60 |
61 | http.Close();
62 |
63 | byte[] response = res.ToArray();
64 |
65 | if (onFinish != null)
66 | onFinish(response, null);
67 |
68 | return response;
69 | }
70 |
71 | private void http_SendProgress(object sender, SocketProgressEventArgs e)
72 | {
73 | if (onUpdate != null)
74 | onUpdate(this, e.BytesProceed, e.TotalBytes);
75 | }
76 |
77 | public override bool Valid()
78 | {
79 | return true;
80 | }
81 |
82 | public override void OnException(Exception e)
83 | {
84 | if (onFinish != null)
85 | onFinish(null, e);
86 | }
87 |
88 | public void Close()
89 | {
90 | if (http != null)
91 | http.Close();
92 | }
93 |
94 | #region Nested type: CreatePostHeader
95 |
96 | public delegate string CreatePostHeader();
97 |
98 | #endregion
99 |
100 | #region Nested type: RequestCompleteHandler
101 |
102 | public delegate void RequestCompleteHandler(byte[] data, Exception e);
103 |
104 | #endregion
105 | }
106 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/FormNetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace osu_common.Libraries.NetLib
5 | {
6 | ///
7 | /// POSTs a byte buffer to a url
8 | ///
9 | public class FormNetRequest : NetRequest
10 | {
11 | private readonly byte[] m_buffer;
12 | private readonly string m_filename;
13 | private readonly string m_labelname;
14 | private Http http;
15 |
16 | public FormNetRequest(string _url)
17 | : base(_url)
18 | {
19 | BufferSize = 8192; //default buffer size is 8kb
20 |
21 | http = new Http();
22 | request = new HttpRequest();
23 | http.Request = request;
24 | }
25 |
26 | public void AddField(string key, string val)
27 | {
28 | request.Items.AddFormField(key,val);
29 | }
30 |
31 | public int BufferSize { get; set; }
32 |
33 | public event RequestStartHandler onStart;
34 | public event RequestUpdateHandler onUpdate;
35 | public event RequestCompleteHandler onFinish;
36 | public HttpRequest request;
37 |
38 | public override void Perform()
39 | {
40 | BlockingPerform();
41 | }
42 |
43 | public string BlockingPerform()
44 | {
45 | //inform subscribers that we have started
46 | if (onStart != null)
47 | onStart();
48 |
49 | MemoryStream res = new MemoryStream();
50 | try
51 | {
52 |
53 | http.SendProgress += http_SendProgress;
54 | http.Post(m_url, request, res);
55 | http.SendProgress -= http_SendProgress;
56 | }
57 | catch
58 | {
59 | }
60 |
61 | http.Close();
62 |
63 | res.Position = 0;
64 | StreamReader sr = new StreamReader(res);
65 |
66 | string response = sr.ReadToEnd();
67 | if (onFinish != null)
68 | onFinish(response, null);
69 |
70 | return response;
71 | }
72 |
73 | private void http_SendProgress(object sender, SocketProgressEventArgs e)
74 | {
75 | if (onUpdate != null)
76 | onUpdate(this, e.BytesProceed, e.TotalBytes);
77 | }
78 |
79 | public override bool Valid()
80 | {
81 | return true;
82 | }
83 |
84 | public override void OnException(Exception e)
85 | {
86 | if (onFinish != null)
87 | onFinish(null, e);
88 | }
89 |
90 | public void Close()
91 | {
92 | if (http != null)
93 | http.Close();
94 | }
95 |
96 | #region Nested type: CreatePostHeader
97 |
98 | public delegate string CreatePostHeader();
99 |
100 | #endregion
101 |
102 | #region Nested type: RequestCompleteHandler
103 |
104 | public delegate void RequestCompleteHandler(string _result, Exception e);
105 |
106 | #endregion
107 | }
108 | }
--------------------------------------------------------------------------------
/Libraries/CryptoHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.IO;
4 | using System.Security.Cryptography;
5 | using System.Text;
6 |
7 | namespace osu_common.Helpers
8 | {
9 | public static class CryptoHelper
10 | {
11 | private static MD5 md5Hasher = MD5.Create();
12 | private static UTF8Encoding utf8Encoding = new UTF8Encoding();
13 | private static NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;
14 |
15 | public static string GetMd5(String path)
16 | {
17 | try
18 | {
19 | using (Stream s = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read))
20 | {
21 | byte[] data = md5Hasher.ComputeHash(s);
22 |
23 | StringBuilder sBuilder = new StringBuilder();
24 |
25 | for (int i = 0; i < data.Length; i++)
26 | sBuilder.Append(data[i].ToString("x2"));
27 |
28 | return sBuilder.ToString();
29 | }
30 | }
31 | catch (Exception e)
32 | {
33 | return "fail" + e;
34 | }
35 | }
36 |
37 | public static string GetMd5String(String instr)
38 | {
39 | return GetMd5String(utf8Encoding.GetBytes(instr));
40 | }
41 |
42 | public static string GetMd5String(byte[] data)
43 | {
44 | try
45 | {
46 | // Convert the input string to a byte array and compute the hash.
47 | data = md5Hasher.ComputeHash(data);
48 | }
49 | catch (Exception)
50 | {
51 | md5Hasher = MD5.Create();
52 | try
53 | {
54 | data = md5Hasher.ComputeHash(data);
55 | }
56 | catch (Exception)
57 | {
58 | return "fail";
59 | }
60 | }
61 |
62 | char[] str = new char[data.Length * 2];
63 | for (int i = 0; i < data.Length; i++)
64 | data[i].ToString("x2", nfi).CopyTo(0, str, i * 2, 2);
65 |
66 | return new String(str);
67 | }
68 |
69 | public static byte[] GetMd5ByteArrayString(String instr)
70 | {
71 | byte[] data;
72 |
73 | try
74 | {
75 | // Convert the input string to a byte array and compute the hash.
76 | data = md5Hasher.ComputeHash(utf8Encoding.GetBytes(instr));
77 | }
78 | catch (Exception)
79 | {
80 | md5Hasher = MD5.Create();
81 | try
82 | {
83 | data = md5Hasher.ComputeHash(utf8Encoding.GetBytes(instr));
84 | }
85 | catch (Exception)
86 | {
87 | return null;
88 | }
89 | }
90 | // Create a new Stringbuilder to collect the bytes
91 | // and create a string.
92 | //StringBuilder sBuilder = new StringBuilder();
93 |
94 | return data;
95 |
96 | }
97 | }
98 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRequestItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.ComponentModel;
4 | using System.Globalization;
5 | using System.IO;
6 | using System.Text;
7 |
8 | namespace osu_common.Libraries.NetLib
9 | {
10 | [TypeConverter("Design.HttpRequestItemConverter, Design")]
11 | public abstract class HttpRequestItem
12 | {
13 | private static readonly byte[] UnsafeChars = Encoding.ASCII.GetBytes("+&*%<>\"#{}|\\^~[]'?!=/:$");
14 | private bool canonicalized = true;
15 | protected internal HttpRequest owner_;
16 |
17 | [DefaultValue(true)]
18 | public bool Canonicalized
19 | {
20 | get { return canonicalized; }
21 | set
22 | {
23 | if (canonicalized != value)
24 | {
25 | canonicalized = value;
26 | Update();
27 | }
28 | }
29 | }
30 |
31 | [Browsable(false)]
32 | public HttpRequest Owner
33 | {
34 | get { return owner_; }
35 | }
36 |
37 | [DefaultValue(0)]
38 | public int Tag { get; set; }
39 |
40 | protected internal abstract void AddData(byte[] data, int index, int length);
41 | protected internal abstract void AfterAddData();
42 |
43 | protected string GetCanonicalizedValue(string theValue)
44 | {
45 | if (!Canonicalized || ((Owner != null) && Owner.IsMultiPart()))
46 | {
47 | return theValue;
48 | }
49 | byte[] bytes = Encoding.UTF8.GetBytes(theValue);
50 | StringBuilder builder = new StringBuilder();
51 | for (int i = 0; i < bytes.Length; i++)
52 | {
53 | if (IsUnsafeChar(bytes[i]) || (bytes[i] >= 0x80))
54 | {
55 | builder.Append("%" +
56 | Convert.ToInt16(bytes[i], CultureInfo.InvariantCulture).ToString("X2",
57 | CultureInfo.
58 | InvariantCulture));
59 | }
60 | else if (bytes[i] == 0x20)
61 | {
62 | builder.Append('+');
63 | }
64 | else
65 | {
66 | builder.Append(Convert.ToChar(bytes[i], CultureInfo.InvariantCulture));
67 | }
68 | }
69 | return builder.ToString();
70 | }
71 |
72 | public abstract Stream GetData();
73 |
74 | private bool IsUnsafeChar(byte charCode)
75 | {
76 | for (int i = 0; i < UnsafeChars.Length; i++)
77 | {
78 | if (UnsafeChars[i] == charCode)
79 | {
80 | return true;
81 | }
82 | }
83 | return false;
84 | }
85 |
86 | protected internal virtual void ParseHeader(IList header, HeaderFieldList fieldList)
87 | {
88 | }
89 |
90 | protected void Update()
91 | {
92 | if (Owner != null)
93 | {
94 | Owner.Update();
95 | }
96 | }
97 | }
98 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/NetManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 |
4 | namespace osu_common.Libraries.NetLib
5 | {
6 | ///
7 | /// Updated Netmanager class. Uses a thread pool to service
8 | /// request objects.
9 | ///
10 | public static class NetManager
11 | {
12 | static long lastRequestTick;
13 | static int chainedFastRequests;
14 |
15 | private static readonly object RequestLock = new object();
16 |
17 | const int DELAY_BETWEEN_REQUESTS = 150;
18 |
19 | ///
20 | /// Adds a request to the application threadpool
21 | ///
22 | /// A NetRequest object that we want performed
23 | /// true if the request can be added
24 | public static bool AddRequest(NetRequest request)
25 | {
26 | if (request == null) return false;
27 |
28 | bool requireDelay = false;
29 | int delayLength;
30 |
31 | lock (RequestLock)
32 | {
33 | long nowTick = DateTime.Now.Ticks;
34 | if (nowTick - lastRequestTick < TimeSpan.TicksPerMillisecond * DELAY_BETWEEN_REQUESTS)
35 | {
36 | requireDelay = true;
37 | chainedFastRequests++;
38 | }
39 | else
40 | {
41 | chainedFastRequests = 0;
42 | }
43 |
44 | delayLength = chainedFastRequests * DELAY_BETWEEN_REQUESTS;
45 | lastRequestTick = nowTick;
46 | }
47 |
48 | ParameterizedThreadStart pts = delegate
49 | {
50 | try
51 | {
52 | if (requireDelay)
53 | {
54 | request.IsQueued = true;
55 | Thread.Sleep(delayLength);
56 | request.IsQueued = false;
57 | }
58 |
59 | if (request.AbortRequested) return;
60 |
61 | request.Perform();
62 | }
63 | catch (ThreadAbortException)
64 | {
65 | }
66 | catch (Exception ex)
67 | {
68 | request.OnException(ex);
69 | }
70 | };
71 |
72 |
73 | Thread t = new Thread(pts);
74 | t.Priority = ThreadPriority.Highest;
75 | t.IsBackground = true;
76 | t.Start();
77 |
78 | request.thread = t;
79 |
80 | return true;
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # User-specific files
2 | *.suo
3 | *.user
4 | *.sln.docstates
5 |
6 | # Build results
7 | [Dd]ebug/
8 | [Dd]ebugPublic/
9 | [Rr]elease/
10 | [Rr]eleases/
11 | x64/
12 | build/
13 | bld/
14 | [Bb]in/
15 | [Oo]bj/
16 |
17 | # Roslyn cache directories
18 | *.ide/
19 |
20 | # MSTest test Results
21 | [Tt]est[Rr]esult*/
22 | [Bb]uild[Ll]og.*
23 |
24 | #NUNIT
25 | *.VisualState.xml
26 | TestResult.xml
27 |
28 | # Build Results of an ATL Project
29 | [Dd]ebugPS/
30 | [Rr]eleasePS/
31 | dlldata.c
32 |
33 | *_i.c
34 | *_p.c
35 | *_i.h
36 | *.ilk
37 | *.meta
38 | *.obj
39 | *.pch
40 | *.pdb
41 | *.pgc
42 | *.pgd
43 | *.rsp
44 | *.sbr
45 | *.tlb
46 | *.tli
47 | *.tlh
48 | *.tmp
49 | *.tmp_proj
50 | *.log
51 | *.vspscc
52 | *.vssscc
53 | .builds
54 | *.pidb
55 | *.svclog
56 | *.scc
57 |
58 | # Chutzpah Test files
59 | _Chutzpah*
60 |
61 | # Visual C++ cache files
62 | ipch/
63 | *.aps
64 | *.ncb
65 | *.opensdf
66 | *.sdf
67 | *.cachefile
68 |
69 | # Visual Studio profiler
70 | *.psess
71 | *.vsp
72 | *.vspx
73 |
74 | # TFS 2012 Local Workspace
75 | $tf/
76 |
77 | # Guidance Automation Toolkit
78 | *.gpState
79 |
80 | # ReSharper is a .NET coding add-in
81 | _ReSharper*/
82 | *.[Rr]e[Ss]harper
83 | *.DotSettings.user
84 |
85 | # JustCode is a .NET coding addin-in
86 | .JustCode
87 |
88 | # TeamCity is a build add-in
89 | _TeamCity*
90 |
91 | # DotCover is a Code Coverage Tool
92 | *.dotCover
93 |
94 | # NCrunch
95 | _NCrunch_*
96 | .*crunch*.local.xml
97 |
98 | # MightyMoose
99 | *.mm.*
100 | AutoTest.Net/
101 |
102 | # Web workbench (sass)
103 | .sass-cache/
104 |
105 | # Installshield output folder
106 | [Ee]xpress/
107 |
108 | # DocProject is a documentation generator add-in
109 | DocProject/buildhelp/
110 | DocProject/Help/*.HxT
111 | DocProject/Help/*.HxC
112 | DocProject/Help/*.hhc
113 | DocProject/Help/*.hhk
114 | DocProject/Help/*.hhp
115 | DocProject/Help/Html2
116 | DocProject/Help/html
117 |
118 | # Click-Once directory
119 | publish/
120 |
121 | # Publish Web Output
122 | *.[Pp]ublish.xml
123 | *.azurePubxml
124 | ## TODO: Comment the next line if you want to checkin your
125 | ## web deploy settings but do note that will include unencrypted
126 | ## passwords
127 | *.pubxml
128 |
129 | # NuGet Packages Directory
130 | packages/*
131 | ## TODO: If the tool you use requires repositories.config
132 | ## uncomment the next line
133 | #!packages/repositories.config
134 |
135 | # Enable "build/" folder in the NuGet Packages folder since
136 | # NuGet packages use it for MSBuild targets.
137 | # This line needs to be after the ignore of the build folder
138 | # (and the packages folder if the line above has been uncommented)
139 | !packages/build/
140 |
141 | # Windows Azure Build Output
142 | csx/
143 | *.build.csdef
144 |
145 | # Windows Store app package directory
146 | AppPackages/
147 |
148 | # Others
149 | sql/
150 | *.Cache
151 | ClientBin/
152 | [Ss]tyle[Cc]op.*
153 | ~$*
154 | *~
155 | *.dbmdl
156 | *.dbproj.schemaview
157 | *.pfx
158 | *.publishsettings
159 | node_modules/
160 |
161 | # RIA/Silverlight projects
162 | Generated_Code/
163 |
164 | # Backup & report files from converting an old project file
165 | # to a newer Visual Studio version. Backup files are not needed,
166 | # because we have git ;-)
167 | _UpgradeReport_Files/
168 | Backup*/
169 | UpgradeLog*.XML
170 | UpgradeLog*.htm
171 |
172 | # SQL Server files
173 | *.mdf
174 | *.ldf
175 |
176 | # Business Intelligence projects
177 | *.rdl.data
178 | *.bim.layout
179 | *.bim_*.settings
180 |
181 | # Microsoft Fakes
182 | FakesAssemblies/
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/BZip2/BZip2Exception.cs:
--------------------------------------------------------------------------------
1 | // BZip2.cs
2 | //
3 | // Copyright 2004 John Reilly
4 | //
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (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, write to the Free Software
17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 | //
19 | // Linking this library statically or dynamically with other modules is
20 | // making a combined work based on this library. Thus, the terms and
21 | // conditions of the GNU General Public License cover the whole
22 | // combination.
23 | //
24 | // As a special exception, the copyright holders of this library give you
25 | // permission to link this library with independent modules to produce an
26 | // executable, regardless of the license terms of these independent
27 | // modules, and to copy and distribute the resulting executable under
28 | // terms of your choice, provided that you also meet, for each linked
29 | // independent module, the terms and conditions of the license of that
30 | // module. An independent module is a module which is not derived from
31 | // or based on this library. If you modify this library, you may extend
32 | // this exception to your version of the library, but you are not
33 | // obligated to do so. If you do not wish to do so, delete this
34 | // exception statement from your version.
35 |
36 | using System;
37 |
38 | #if !NETCF_1_0 && !NETCF_2_0
39 | using System.Runtime.Serialization;
40 | #endif
41 |
42 | using ICSharpCode.SharpZipLib;
43 |
44 | namespace ICSharpCode.SharpZipLib.BZip2
45 | {
46 | ///
47 | /// BZip2Exception represents exceptions specific to Bzip2 algorithm
48 | ///
49 | #if !NETCF_1_0 && !NETCF_2_0
50 | #endif
51 | public class BZip2Exception : SharpZipBaseException
52 | {
53 |
54 | #if !NETCF_1_0 && !NETCF_2_0
55 | ///
56 | /// Deserialization constructor
57 | ///
58 | /// for this constructor
59 | /// for this constructor
60 | protected BZip2Exception(SerializationInfo info, StreamingContext context)
61 | : base(info, context)
62 |
63 | {
64 | }
65 | #endif
66 | ///
67 | /// Initialise a new instance of BZip2Exception.
68 | ///
69 | public BZip2Exception()
70 | {
71 | }
72 |
73 | ///
74 | /// Initialise a new instance of BZip2Exception with its message set to message.
75 | ///
76 | /// The message describing the error.
77 | public BZip2Exception(string message) : base(message)
78 | {
79 | }
80 |
81 | ///
82 | /// Initialise an instance of BZip2Exception
83 | ///
84 | /// A message describing the error.
85 | /// The exception that is the cause of the current exception.
86 | public BZip2Exception(string message, Exception exception)
87 | : base(message, exception)
88 | {
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Libraries/NetLib/FileUploadNetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Threading;
4 |
5 | namespace osu_common.Libraries.NetLib
6 | {
7 | ///
8 | /// POSTs a byte buffer to a url
9 | ///
10 | public class FileUploadNetRequest : NetRequest
11 | {
12 | private readonly byte[] m_buffer;
13 | public string Filename;
14 | public readonly string Label;
15 | private Http http;
16 | public HttpRequest request = new HttpRequest();
17 |
18 | public FileUploadNetRequest(string _url, byte[] _buffer, string _filename, string _labelname)
19 | : base(_url)
20 | {
21 | m_buffer = _buffer;
22 | BufferSize = 8192; //default buffer size is 8kb
23 | Filename = _filename;
24 | Label = _labelname;
25 | }
26 |
27 | public int BufferSize { get; set; }
28 |
29 | public event RequestStartHandler onStart;
30 | public event RequestUpdateHandler onUpdate;
31 | public event RequestCompleteHandler onFinish;
32 |
33 | public override void Perform()
34 | {
35 | BlockingPerform();
36 | }
37 |
38 | public string BlockingPerform()
39 | {
40 | //inform subscribers that we have started
41 | if (onStart != null)
42 | onStart();
43 |
44 | http = new Http();
45 | http.Request = request;
46 |
47 | MemoryStream res = new MemoryStream();
48 | try
49 | {
50 | SubmitFileRequestItem i = request.Items.AddSubmitFile(Filename, Label);
51 | i.AddDataArray(m_buffer);
52 | http.SendProgress += http_SendProgress;
53 | http.Post(m_url, request, res);
54 | http.SendProgress -= http_SendProgress;
55 | }
56 | catch (ThreadAbortException)
57 | {
58 | http.Close();
59 |
60 | if (onFinish != null)
61 | onFinish(null, new AbortedException());
62 |
63 | return null;
64 | }
65 | catch (Exception e)
66 | {
67 | http.Close();
68 |
69 | if (onFinish != null)
70 | onFinish(null, e);
71 |
72 | return null;
73 | }
74 |
75 | http.Close();
76 |
77 | res.Position = 0;
78 | StreamReader sr = new StreamReader(res);
79 |
80 | string response = sr.ReadToEnd();
81 |
82 | if (onFinish != null)
83 | onFinish(response, null);
84 |
85 | return response;
86 | }
87 |
88 | private void http_SendProgress(object sender, SocketProgressEventArgs e)
89 | {
90 | if (onUpdate != null)
91 | onUpdate(this, e.BytesProceed, e.TotalBytes);
92 | }
93 |
94 | public override bool Valid()
95 | {
96 | return true;
97 | }
98 |
99 | public override void OnException(Exception e)
100 | {
101 | if (onFinish != null)
102 | onFinish(null, e);
103 | }
104 |
105 | public void Close()
106 | {
107 | if (http != null)
108 | http.Close();
109 | }
110 |
111 | #region Nested type: CreatePostHeader
112 |
113 | public delegate string CreatePostHeader();
114 |
115 | #endregion
116 |
117 | #region Nested type: RequestCompleteHandler
118 |
119 | public delegate void RequestCompleteHandler(string _result, Exception e);
120 |
121 | #endregion
122 | }
123 | }
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/Zip/ZipException.cs:
--------------------------------------------------------------------------------
1 | // ZipException.cs
2 | //
3 | // Copyright (C) 2001 Mike Krueger
4 | //
5 | // This file was translated from java, it was part of the GNU Classpath
6 | // Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
7 | //
8 | // This program is free software; you can redistribute it and/or
9 | // modify it under the terms of the GNU General Public License
10 | // as published by the Free Software Foundation; either version 2
11 | // of the License, or (at your option) any later version.
12 | //
13 | // This program is distributed in the hope that it will be useful,
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 | // GNU General Public License for more details.
17 | //
18 | // You should have received a copy of the GNU General Public License
19 | // along with this program; if not, write to the Free Software
20 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 | //
22 | // Linking this library statically or dynamically with other modules is
23 | // making a combined work based on this library. Thus, the terms and
24 | // conditions of the GNU General Public License cover the whole
25 | // combination.
26 | //
27 | // As a special exception, the copyright holders of this library give you
28 | // permission to link this library with independent modules to produce an
29 | // executable, regardless of the license terms of these independent
30 | // modules, and to copy and distribute the resulting executable under
31 | // terms of your choice, provided that you also meet, for each linked
32 | // independent module, the terms and conditions of the license of that
33 | // module. An independent module is a module which is not derived from
34 | // or based on this library. If you modify this library, you may extend
35 | // this exception to your version of the library, but you are not
36 | // obligated to do so. If you do not wish to do so, delete this
37 | // exception statement from your version.
38 |
39 | using System;
40 |
41 | #if !NETCF_1_0 && !NETCF_2_0
42 | using System.Runtime.Serialization;
43 | #endif
44 |
45 | namespace ICSharpCode.SharpZipLib.Zip
46 | {
47 |
48 | ///
49 | /// Represents exception conditions specific to Zip archive handling
50 | ///
51 | #if !NETCF_1_0 && !NETCF_2_0
52 | #endif
53 | public class ZipException : SharpZipBaseException
54 | {
55 | #if !NETCF_1_0 && !NETCF_2_0
56 | ///
57 | /// Deserialization constructor
58 | ///
59 | /// for this constructor
60 | /// for this constructor
61 | protected ZipException(SerializationInfo info, StreamingContext context )
62 | : base( info, context )
63 | {
64 | }
65 | #endif
66 |
67 | ///
68 | /// Initializes a new instance of the ZipException class.
69 | ///
70 | public ZipException()
71 | {
72 | }
73 |
74 | ///
75 | /// Initializes a new instance of the ZipException class with a specified error message.
76 | ///
77 | /// The error message that explains the reason for the exception.
78 | public ZipException(string message)
79 | : base(message)
80 | {
81 | }
82 |
83 | ///
84 | /// Initialise a new instance of ZipException.
85 | ///
86 | /// A message describing the error.
87 | /// The exception that is the cause of the current exception.
88 | public ZipException(string message, Exception exception)
89 | : base(message, exception)
90 | {
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/Checksums/IChecksum.cs:
--------------------------------------------------------------------------------
1 | // IChecksum.cs - Interface to compute a data checksum
2 | // Copyright (C) 2001 Mike Krueger
3 | //
4 | // This file was translated from java, it was part of the GNU Classpath
5 | // Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
6 | //
7 | // This program is free software; you can redistribute it and/or
8 | // modify it under the terms of the GNU General Public License
9 | // as published by the Free Software Foundation; either version 2
10 | // of the License, or (at your option) any later version.
11 | //
12 | // This program is distributed in the hope that it will be useful,
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | // GNU General Public License for more details.
16 | //
17 | // You should have received a copy of the GNU General Public License
18 | // along with this program; if not, write to the Free Software
19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 | //
21 | // Linking this library statically or dynamically with other modules is
22 | // making a combined work based on this library. Thus, the terms and
23 | // conditions of the GNU General Public License cover the whole
24 | // combination.
25 | //
26 | // As a special exception, the copyright holders of this library give you
27 | // permission to link this library with independent modules to produce an
28 | // executable, regardless of the license terms of these independent
29 | // modules, and to copy and distribute the resulting executable under
30 | // terms of your choice, provided that you also meet, for each linked
31 | // independent module, the terms and conditions of the license of that
32 | // module. An independent module is a module which is not derived from
33 | // or based on this library. If you modify this library, you may extend
34 | // this exception to your version of the library, but you are not
35 | // obligated to do so. If you do not wish to do so, delete this
36 | // exception statement from your version.
37 |
38 | namespace ICSharpCode.SharpZipLib.Checksums
39 | {
40 |
41 | ///
42 | /// Interface to compute a data checksum used by checked input/output streams.
43 | /// A data checksum can be updated by one byte or with a byte array. After each
44 | /// update the value of the current checksum can be returned by calling
45 | /// getValue. The complete checksum object can also be reset
46 | /// so it can be used again with new data.
47 | ///
48 | public interface IChecksum
49 | {
50 | ///
51 | /// Returns the data checksum computed so far.
52 | ///
53 | long Value
54 | {
55 | get;
56 | }
57 |
58 | ///
59 | /// Resets the data checksum as if no update was ever called.
60 | ///
61 | void Reset();
62 |
63 | ///
64 | /// Adds one byte to the data checksum.
65 | ///
66 | ///
67 | /// the data value to add. The high byte of the int is ignored.
68 | ///
69 | void Update(int value);
70 |
71 | ///
72 | /// Updates the data checksum with the bytes taken from the array.
73 | ///
74 | ///
75 | /// buffer an array of bytes
76 | ///
77 | void Update(byte[] buffer);
78 |
79 | ///
80 | /// Adds the byte array to the data checksum.
81 | ///
82 | ///
83 | /// The buffer which contains the data
84 | ///
85 | ///
86 | /// The offset in the buffer where the data starts
87 | ///
88 | ///
89 | /// the number of data bytes to add.
90 | ///
91 | void Update(byte[] buffer, int offset, int count);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/HistoryManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using osu_common.Libraries.NetLib;
5 | using System.Windows.Forms;
6 | using System.Threading;
7 |
8 | namespace puush
9 | {
10 | internal static class HistoryManager
11 | {
12 | internal static List HistoryItems = new List();
13 |
14 | internal static bool UpdateScheduled;
15 |
16 | internal static void Update()
17 | {
18 | if (!puush.IsLoggedIn)
19 | return;
20 |
21 | FormNetRequest request = new FormNetRequest(puush.getApiUrl("hist"));
22 | request.request.Items.AddFormField("k", puush.config.GetValue("key", ""));
23 | request.onFinish += new FormNetRequest.RequestCompleteHandler(historyRetrieval_onFinish);
24 |
25 | NetManager.AddRequest(request);
26 | }
27 |
28 | internal static void historyRetrieval_onFinish(string _result, Exception e)
29 | {
30 | // if (!UpdateScheduled)
31 | // {
32 | // UpdateScheduled = true;
33 |
34 | // MainForm.threadMeSome(delegate {
35 | // Thread.Sleep(60000 * 5); //wait 5 minutes
36 | // UpdateScheduled = false;
37 | // Update();
38 | // });
39 | // }
40 |
41 | if (e != null) return;
42 |
43 | MainForm.Instance.Invoke(delegate
44 | {
45 | ContextMenuStrip menu = MainForm.Instance.contextMenuStrip1;
46 |
47 | foreach (HistoryItem i in HistoryItems)
48 | {
49 | menu.Items.Remove(i);
50 | i.Dispose();
51 | }
52 |
53 | HistoryItems.Clear();
54 |
55 | int response;
56 |
57 | string[] lines = _result.Split('\n');
58 |
59 | if (!Int32.TryParse(lines[0], out response))
60 | response = -2;
61 |
62 | switch (response)
63 | {
64 | case -1:
65 | //puush.HandleInvalidAuthentication();
66 | //todo: reimplement this after server-side handles correctly.
67 | return;
68 | case -2:
69 | //unknown/other
70 | return;
71 | }
72 |
73 |
74 | int displayCount = 5;
75 |
76 | try
77 | {
78 |
79 | bool firstLine = true;
80 | foreach (string line in lines)
81 | {
82 | if (firstLine)
83 | {
84 | firstLine = false;
85 | continue;
86 | }
87 |
88 | if (displayCount-- == 0) break;
89 |
90 | if (line.Length == 0) break;
91 |
92 | string[] parts = line.Split(',');
93 |
94 | int id = Int32.Parse(parts[0]);
95 | string date = parts[1];
96 | string url = parts[2];
97 | string filename = parts[3];
98 | int viewCount = Int32.Parse(parts[4]);
99 |
100 | HistoryItems.Insert(0,new HistoryItem(id, date, url, filename,viewCount));
101 | }
102 | }
103 | catch { }
104 |
105 | foreach (HistoryItem i in HistoryItems) menu.Items.Insert(4, i);
106 |
107 | });
108 |
109 | }
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/Libraries/NetLib/MultiStream.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Collections;
5 | using System.IO;
6 |
7 | public class MultiStream : Stream
8 | {
9 | private long position;
10 | private ArrayList streamList = new ArrayList();
11 |
12 | public void AddStream(Stream stream)
13 | {
14 | this.streamList.Add(stream);
15 | }
16 |
17 | public override void Close()
18 | {
19 | foreach (Stream stream in this.streamList)
20 | {
21 | stream.Close();
22 | }
23 | base.Close();
24 | }
25 |
26 | public override void Flush()
27 | {
28 | }
29 |
30 | public override int Read(byte[] buffer, int offset, int count)
31 | {
32 | long num = 0L;
33 | int num2 = 0;
34 | int num3 = offset;
35 | foreach (Stream stream in this.streamList)
36 | {
37 | if (this.position < (num + stream.Length))
38 | {
39 | stream.Position = this.position - num;
40 | int num4 = stream.Read(buffer, num3, count);
41 | num2 += num4;
42 | num3 += num4;
43 | this.position += num4;
44 | if (num4 >= count)
45 | {
46 | return num2;
47 | }
48 | count -= num4;
49 | }
50 | num += stream.Length;
51 | }
52 | return num2;
53 | }
54 |
55 | public override long Seek(long offset, SeekOrigin origin)
56 | {
57 | long length = this.Length;
58 | switch (origin)
59 | {
60 | case SeekOrigin.Begin:
61 | this.position = offset;
62 | break;
63 |
64 | case SeekOrigin.Current:
65 | this.position += offset;
66 | break;
67 |
68 | case SeekOrigin.End:
69 | this.position = length - offset;
70 | break;
71 | }
72 | if (this.position > length)
73 | {
74 | this.position = length;
75 | }
76 | else if (this.position < 0L)
77 | {
78 | this.position = 0L;
79 | }
80 | return this.position;
81 | }
82 |
83 | public override void SetLength(long value)
84 | {
85 | }
86 |
87 | public override void Write(byte[] buffer, int offset, int count)
88 | {
89 | }
90 |
91 | public override bool CanRead
92 | {
93 | get
94 | {
95 | return true;
96 | }
97 | }
98 |
99 | public override bool CanSeek
100 | {
101 | get
102 | {
103 | return true;
104 | }
105 | }
106 |
107 | public override bool CanWrite
108 | {
109 | get
110 | {
111 | return false;
112 | }
113 | }
114 |
115 | public override long Length
116 | {
117 | get
118 | {
119 | long num = 0L;
120 | foreach (Stream stream in this.streamList)
121 | {
122 | num += stream.Length;
123 | }
124 | return num;
125 | }
126 | }
127 |
128 | public override long Position
129 | {
130 | get
131 | {
132 | return this.position;
133 | }
134 | set
135 | {
136 | this.Seek(value, SeekOrigin.Begin);
137 | }
138 | }
139 | }
140 | }
141 |
142 |
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/SharpZipBaseException.cs:
--------------------------------------------------------------------------------
1 | // SharpZipBaseException.cs
2 | //
3 | // Copyright 2004 John Reilly
4 | //
5 | // This program is free software; you can redistribute it and/or
6 | // modify it under the terms of the GNU General Public License
7 | // as published by the Free Software Foundation; either version 2
8 | // of the License, or (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, write to the Free Software
17 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 | //
19 | // Linking this library statically or dynamically with other modules is
20 | // making a combined work based on this library. Thus, the terms and
21 | // conditions of the GNU General Public License cover the whole
22 | // combination.
23 | //
24 | // As a special exception, the copyright holders of this library give you
25 | // permission to link this library with independent modules to produce an
26 | // executable, regardless of the license terms of these independent
27 | // modules, and to copy and distribute the resulting executable under
28 | // terms of your choice, provided that you also meet, for each linked
29 | // independent module, the terms and conditions of the license of that
30 | // module. An independent module is a module which is not derived from
31 | // or based on this library. If you modify this library, you may extend
32 | // this exception to your version of the library, but you are not
33 | // obligated to do so. If you do not wish to do so, delete this
34 | // exception statement from your version.
35 |
36 | using System;
37 |
38 | #if !NETCF_1_0 && !NETCF_2_0
39 | using System.Runtime.Serialization;
40 | #endif
41 |
42 | namespace ICSharpCode.SharpZipLib
43 | {
44 | ///
45 | /// SharpZipBaseException is the base exception class for the SharpZipLibrary.
46 | /// All library exceptions are derived from this.
47 | ///
48 | /// NOTE: Not all exceptions thrown will be derived from this class.
49 | /// A variety of other exceptions are possible for example
50 | #if !NETCF_1_0 && !NETCF_2_0
51 | #endif
52 | public class SharpZipBaseException : ApplicationException
53 | {
54 | #if !NETCF_1_0 && !NETCF_2_0
55 | ///
56 | /// Deserialization constructor
57 | ///
58 | /// for this constructor
59 | /// for this constructor
60 | protected SharpZipBaseException(SerializationInfo info, StreamingContext context )
61 | : base( info, context )
62 | {
63 | }
64 | #endif
65 |
66 | ///
67 | /// Initializes a new instance of the SharpZipBaseException class.
68 | ///
69 | public SharpZipBaseException()
70 | {
71 | }
72 |
73 | ///
74 | /// Initializes a new instance of the SharpZipBaseException class with a specified error message.
75 | ///
76 | /// A message describing the exception.
77 | public SharpZipBaseException(string message)
78 | : base(message)
79 | {
80 | }
81 |
82 | ///
83 | /// Initializes a new instance of the SharpZipBaseException class with a specified
84 | /// error message and a reference to the inner exception that is the cause of this exception.
85 | ///
86 | /// A message describing the exception.
87 | /// The inner exception
88 | public SharpZipBaseException(string message, Exception innerException)
89 | : base(message, innerException)
90 | {
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/MainForm.Capture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Drawing;
5 | using Gma.UserActivityMonitor;
6 | using System.Windows.Forms;
7 |
8 | namespace puush
9 | {
10 | partial class MainForm
11 | {
12 | private static object SelectionLock = new object();
13 |
14 | bool updatePosition = true;
15 |
16 | private void StartSelection()
17 | {
18 | if (!puush.EnsureLogin()) return;
19 |
20 | lock (SelectionLock) //ensure we only enter here once.
21 | {
22 | if (captureMode) return; //we are already mid-capture.
23 |
24 | HookManager.MouseMove += HookManager_MouseMove;
25 | HookManager.MouseDown += HookManager_MouseDown;
26 | HookManager.MouseUp += HookManager_MouseUp;
27 | HookManager.KeyDown += HookManager_KeyDown;
28 |
29 | captureMode = true;
30 | }
31 |
32 | p1 = new Point(-1, -1);
33 | p2 = new Point(-1, -1);
34 |
35 | if (selectionForm != null)
36 | selectionForm.Dispose();
37 |
38 | updatePosition = puush.config.GetValue("selectionrectangle", true);
39 | if (!updatePosition && puush.config.GetValue("notificationsound", true)) Console.Beep(500, 150);
40 |
41 | selectionForm = new ScreenSelection();
42 | selectionForm.Show();
43 |
44 | UpdateArbitraryPosition(Cursor.Position);
45 | }
46 |
47 | private void EndSelection()
48 | {
49 | HookManager.MouseMove -= HookManager_MouseMove;
50 | HookManager.MouseDown -= HookManager_MouseDown;
51 | HookManager.MouseUp -= HookManager_MouseUp;
52 | HookManager.KeyDown -= HookManager_KeyDown;
53 |
54 | //Cursor.Current = Cursors.Arrow;
55 |
56 | captureMode = false;
57 | selectionMode = false;
58 |
59 | if (selectionForm != null)
60 | {
61 | selectionForm.Close();
62 | selectionForm.Dispose();
63 | }
64 | selectionForm = null;
65 | }
66 |
67 | bool captureMode;
68 | bool selectionMode;
69 | ScreenSelection selectionForm;
70 | Point p1;
71 | Point p2;
72 |
73 | void HookManager_MouseUp(object sender, MouseEventExtArgs e)
74 | {
75 | if (!selectionMode) return;
76 |
77 | EndSelection();
78 |
79 | if (Math.Abs(p1.X - p2.X) + Math.Abs(p1.Y - p2.Y) > 10 && p2.X != -1 && p2.Y != -1)
80 | {
81 | Invoke(delegate { ScreenshotCapture.Run(Math.Min(p1.X, p2.X), Math.Max(p1.X, p2.X), Math.Min(p1.Y, p2.Y), Math.Max(p1.Y, p2.Y)); });
82 | }
83 | else
84 | Invoke(StartSelection);
85 |
86 | e.Handled = true;
87 | }
88 |
89 | void HookManager_MouseDown(object sender, MouseEventExtArgs e)
90 | {
91 | //selectionForm.panel1.Visible = true;
92 | if (selectionForm != null) selectionForm.Opacity = updatePosition ? 0.3 : 0.05;
93 | selectionMode = true;
94 | e.Handled = true;
95 |
96 | p1 = e.Location;
97 | }
98 |
99 | void HookManager_MouseMove(object sender, MouseEventExtArgs e)
100 | {
101 | if (selectionMode)
102 | {
103 | p2 = e.Location;
104 |
105 | if (selectionForm != null && updatePosition)
106 | selectionForm.Bounds = new Rectangle(
107 | Math.Min(p1.X, p2.X) - 1, Math.Min(p1.Y, p2.Y) - 1,
108 | Math.Max(p1.X, p2.X) - selectionForm.Location.X + 2, Math.Max(p1.Y, p2.Y) - selectionForm.Location.Y + 2);
109 | }
110 | else
111 | {
112 | UpdateArbitraryPosition(e.Location);
113 | }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/Libraries/NetLib/StringCollectionEx.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Collections.Specialized;
5 | using System.Globalization;
6 | using System.IO;
7 |
8 | public class StringCollectionEx : StringCollection
9 | {
10 | public bool AddTextStr(string text, bool addToLastString)
11 | {
12 | foreach (string str in StringUtils.GetStringArray(text))
13 | {
14 | if (addToLastString && (base.Count > 0))
15 | {
16 | StringCollection strings;
17 | int num2;
18 | (strings = this)[num2 = base.Count - 1] = strings[num2] + str;
19 | addToLastString = false;
20 | }
21 | else
22 | {
23 | base.Add(str);
24 | }
25 | }
26 | return (((text.Length == 1) && (text[0] != '\n')) || (((text.Length > 1) && (text[text.Length - 2] != '\r')) && (text[text.Length - 1] != '\n')));
27 | }
28 |
29 | public bool Contains(string theValue, bool ignoreCase)
30 | {
31 | if (!ignoreCase)
32 | {
33 | return base.Contains(theValue);
34 | }
35 | return this.Exists(theValue);
36 | }
37 |
38 | public void CopyTo(StringCollection collection)
39 | {
40 | collection.Clear();
41 | foreach (string str in this)
42 | {
43 | collection.Add(str);
44 | }
45 | }
46 |
47 | private bool Exists(string theValue)
48 | {
49 | StringEnumerator enumerator = base.GetEnumerator();
50 | while (enumerator.MoveNext())
51 | {
52 | if (string.Compare(enumerator.Current, theValue, true, CultureInfo.InvariantCulture) == 0)
53 | {
54 | return true;
55 | }
56 | }
57 | return false;
58 | }
59 |
60 | public bool LoadFromStream(Stream stream, string charSet)
61 | {
62 | return this.LoadFromStream(stream, 0L, false, charSet);
63 | }
64 |
65 | public bool LoadFromStream(Stream stream, long count, bool addToLastString, string charSet)
66 | {
67 | if (count == 0L)
68 | {
69 | count = stream.Length;
70 | }
71 | if (count > 0L)
72 | {
73 | byte[] buffer = new byte[count];
74 | stream.Read(buffer, 0, (int) count);
75 | return this.AddTextStr(Translator.GetString(buffer, charSet), addToLastString);
76 | }
77 | return false;
78 | }
79 |
80 | public void SaveToStream(Stream stream, string charSet)
81 | {
82 | StringEnumerator enumerator = base.GetEnumerator();
83 |
84 | while (enumerator.MoveNext())
85 | {
86 | byte[] bytes = Translator.GetBytes(enumerator.Current, charSet);
87 | stream.Write(bytes, 0, bytes.Length);
88 | stream.WriteByte(13);
89 | stream.WriteByte(10);
90 | }
91 | }
92 |
93 | public string[] ToArray()
94 | {
95 | string[] array = new string[base.Count];
96 | base.CopyTo(array, 0);
97 | return array;
98 | }
99 |
100 | public override string ToString()
101 | {
102 | string[] array = new string[base.Count];
103 | base.CopyTo(array, 0);
104 | return (string.Join("\r\n", array) + "\r\n");
105 | }
106 |
107 | public long StringsSize
108 | {
109 | get
110 | {
111 | long num = 0L;
112 | foreach (string str in this)
113 | {
114 | num += str.Length + "\r\n".Length;
115 | }
116 | return num;
117 | }
118 | }
119 | }
120 | }
121 |
122 |
--------------------------------------------------------------------------------
/Libraries/SharpZipLib/Zip/IEntryFactory.cs:
--------------------------------------------------------------------------------
1 | // IEntryFactory.cs
2 | //
3 | // Copyright 2006 John Reilly
4 | //
5 | // Copyright (C) 2001 Free Software Foundation, Inc.
6 | //
7 | // This program is free software; you can redistribute it and/or
8 | // modify it under the terms of the GNU General Public License
9 | // as published by the Free Software Foundation; either version 2
10 | // of the License, or (at your option) any later version.
11 | //
12 | // This program is distributed in the hope that it will be useful,
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 | // GNU General Public License for more details.
16 | //
17 | // You should have received a copy of the GNU General Public License
18 | // along with this program; if not, write to the Free Software
19 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 | //
21 | // Linking this library statically or dynamically with other modules is
22 | // making a combined work based on this library. Thus, the terms and
23 | // conditions of the GNU General Public License cover the whole
24 | // combination.
25 | //
26 | // As a special exception, the copyright holders of this library give you
27 | // permission to link this library with independent modules to produce an
28 | // executable, regardless of the license terms of these independent
29 | // modules, and to copy and distribute the resulting executable under
30 | // terms of your choice, provided that you also meet, for each linked
31 | // independent module, the terms and conditions of the license of that
32 | // module. An independent module is a module which is not derived from
33 | // or based on this library. If you modify this library, you may extend
34 | // this exception to your version of the library, but you are not
35 | // obligated to do so. If you do not wish to do so, delete this
36 | // exception statement from your version.
37 |
38 | using System;
39 |
40 | using ICSharpCode.SharpZipLib.Core;
41 |
42 | namespace ICSharpCode.SharpZipLib.Zip
43 | {
44 | ///
45 | /// Defines factory methods for creating new values.
46 | ///
47 | public interface IEntryFactory
48 | {
49 | ///
50 | /// Create a for a file given its name
51 | ///
52 | /// The name of the file to create an entry for.
53 | /// Returns a file entry based on the passed.
54 | ZipEntry MakeFileEntry(string fileName);
55 |
56 | ///
57 | /// Create a for a file given its name
58 | ///
59 | /// The name of the file to create an entry for.
60 | /// If true get details from the file system if the file exists.
61 | /// Returns a file entry based on the passed.
62 | ZipEntry MakeFileEntry(string fileName, bool useFileSystem);
63 |
64 | ///
65 | /// Create a for a directory given its name
66 | ///
67 | /// The name of the directory to create an entry for.
68 | /// Returns a directory entry based on the passed.
69 | ZipEntry MakeDirectoryEntry(string directoryName);
70 |
71 | ///
72 | /// Create a for a directory given its name
73 | ///
74 | /// The name of the directory to create an entry for.
75 | /// If true get details from the file system for this directory if it exists.
76 | /// Returns a directory entry based on the passed.
77 | ZipEntry MakeDirectoryEntry(string directoryName, bool useFileSystem);
78 |
79 | ///
80 | /// Get/set the applicable.
81 | ///
82 | INameTransform NameTransform { get; set; }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/QuickStart.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Text;
7 | using System.Windows.Forms;
8 | using System.Diagnostics;
9 | using osu_common.Libraries.NetLib;
10 | using osu_common.Helpers;
11 |
12 | namespace puush
13 | {
14 | public partial class QuickStart : pForm
15 | {
16 | public QuickStart()
17 | {
18 | InitializeComponent();
19 |
20 | groupLogin.Visible = !puush.IsLoggedIn;
21 | buttonClose.Enabled = puush.IsLoggedIn;
22 |
23 | ShowInTaskbar = true;
24 | TopMost = false;
25 | }
26 |
27 | protected override void OnClosed(EventArgs e)
28 | {
29 | MainForm.QuickStart = null;
30 | base.OnClosed(e);
31 | }
32 |
33 | private void button1_Click(object sender, EventArgs e)
34 | {
35 |
36 | puush.config.SetValue("quickstartshown", true);
37 | puush.config.SetValue("startup", checkBox1.Checked);
38 | puush.SetStartupBehaviour();
39 |
40 | Close();
41 | }
42 |
43 | private void textBox_TextChanged(object sender, EventArgs e)
44 | {
45 | UpdateLoginButton();
46 | }
47 |
48 | private void UpdateLoginButton()
49 | {
50 | buttonLogin.Enabled = textBoxUsername.TextLength > 0 && textBoxPassword.TextLength > 0;
51 | }
52 |
53 | private void button2_Click(object sender, EventArgs e)
54 | {
55 | Process.Start("http://puush.me/register/");
56 | }
57 |
58 | private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
59 | {
60 | Process.Start("http://puush.me/reset_password");
61 | }
62 |
63 | private void buttonLogin_Click(object sender, EventArgs e)
64 | {
65 | FormNetRequest loginRequest = new FormNetRequest(puush.getApiUrl("auth"));
66 | loginRequest.AddField("e", textBoxUsername.Text);
67 | loginRequest.AddField("p", textBoxPassword.Text);
68 | loginRequest.AddField("z", "poop");
69 | loginRequest.onFinish += login_onFinish;
70 | NetManager.AddRequest(loginRequest);
71 |
72 | groupLogin.Enabled = false;
73 | }
74 |
75 | void login_onFinish(string _result, Exception e)
76 | {
77 | Invoke((MethodInvoker)delegate
78 | {
79 | groupLogin.Enabled = true;
80 |
81 | int status = -1;
82 |
83 | string[] split = _result.Split(',');
84 |
85 | try
86 | {
87 | status = Int32.Parse(split[0]);
88 | }
89 | catch
90 | {
91 | MessageBox.Show(this, "Connection with server went wrong. Please check your connection and try again.", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
92 | return;
93 | }
94 |
95 | if (status < 0)
96 | {
97 | MessageBox.Show(this, "The username or password you entered is incorrect.", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
98 | }
99 | else
100 | {
101 | puush.config.SetValue("username", textBoxUsername.Text);
102 | puush.config.SetValue("key", split[1]);
103 |
104 | groupLogin.Visible = false;
105 | buttonClose.Enabled = true;
106 |
107 | buttonClose.Select();
108 | }
109 | });
110 | }
111 |
112 | private void textBoxUsername_KeyDown(object sender, KeyEventArgs e)
113 | {
114 | if (e.KeyCode == Keys.Enter)
115 | {
116 | buttonLogin.PerformClick();
117 | e.Handled = true;
118 | }
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/Libraries/NetLib/FileNetRequest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace osu_common.Libraries.NetLib
5 | {
6 | ///
7 | /// Downloads a file from the internet to a specified location
8 | ///
9 | public class FileNetRequest : NetRequest
10 | {
11 | private readonly string m_filename;
12 | private Http h;
13 |
14 | public FileNetRequest(string _filename, string _url)
15 | : base(_url)
16 | {
17 | m_filename = _filename;
18 | }
19 |
20 | public event RequestStartHandler onStart;
21 | public event RequestUpdateHandler onUpdate;
22 | public event RequestCompleteHandler onFinish;
23 |
24 | FileStream fileStream;
25 |
26 |
27 | public override void Perform()
28 | {
29 | //inform subscribers that we have started
30 | if (onStart != null)
31 | onStart();
32 |
33 | string dir = Path.GetDirectoryName(m_filename);
34 | if (dir != string.Empty && !Directory.Exists(dir))
35 | Directory.CreateDirectory(dir);
36 |
37 | fileStream = new FileStream(m_filename,
38 | FileMode.Create, FileAccess.Write,FileShare.Write,4096);
39 |
40 | try
41 | {
42 | h = new Http();
43 | h.ReceiveProgress += http_ReceiveProgress;
44 | h.Get(m_url, fileStream);
45 | h.Close();
46 | }
47 | catch {
48 | fileStream.Close();
49 | File.Delete(m_filename);
50 | return;
51 | }
52 |
53 | /*int count;
54 | byte[] buf = new byte[8192];
55 |
56 | do
57 | {
58 | //read data into file buffer
59 | count = resStream.Read(buf, 0, buf.Length);
60 |
61 | // make sure we read some data
62 | if (count != 0)
63 | {
64 | fileStream.Write(buf, 0, count);
65 |
66 | //update subscribers
67 | if (onUpdate != null)
68 | onUpdate(this, Convert.ToDouble(fileStream.Position)/
69 | Convert.ToDouble(response.ContentLength));
70 | }
71 | } while (count > 0);*/
72 |
73 | fileStream.Close();
74 | //resStream.Close();
75 |
76 | //inform subscribers that we have finished
77 | if (onFinish != null)
78 | onFinish(m_filename, null);
79 | }
80 |
81 | private void http_ReceiveProgress(object sender, SocketProgressEventArgs e)
82 | {
83 | if (onUpdate != null) onUpdate(this, e.BytesProceed, e.TotalBytes);
84 | }
85 |
86 | public override void Abort()
87 | {
88 | try
89 | {
90 | h.Close();
91 | if (fileStream != null)
92 | fileStream.Close();
93 | File.Delete(m_filename);
94 | }
95 | catch { }
96 |
97 | //inform subscribers that we have finished
98 | if (onFinish != null)
99 | onFinish(m_filename, new Exception("aborted"));
100 | }
101 |
102 | public override bool Valid()
103 | {
104 | //check that the filename given corrosponds to a valid
105 | //path and that the file does not exist
106 | if (File.Exists(m_filename))
107 | {
108 | Console.WriteLine(m_filename + " already exists");
109 | return false;
110 | }
111 |
112 | return true;
113 | }
114 |
115 | public override void OnException(Exception e)
116 | {
117 | if (onFinish != null)
118 | onFinish(null, e);
119 | }
120 |
121 | #region Nested type: RequestCompleteHandler
122 |
123 | public delegate void RequestCompleteHandler(string _fileLocation, Exception e);
124 |
125 | #endregion
126 | }
127 | }
--------------------------------------------------------------------------------
/UpdateAvailableDialog.Designer.cs:
--------------------------------------------------------------------------------
1 | using puush.Properties;
2 | namespace puush
3 | {
4 | partial class UpdateAvailableDialog
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.webBrowser1 = new System.Windows.Forms.WebBrowser();
33 | this.buttonDownload = new System.Windows.Forms.Button();
34 | this.buttonCancel = new System.Windows.Forms.Button();
35 | this.SuspendLayout();
36 | //
37 | // webBrowser1
38 | //
39 | this.webBrowser1.Location = new System.Drawing.Point(12, 12);
40 | this.webBrowser1.MinimumSize = new System.Drawing.Size(20, 20);
41 | this.webBrowser1.Name = "webBrowser1";
42 | this.webBrowser1.Size = new System.Drawing.Size(606, 353);
43 | this.webBrowser1.TabIndex = 0;
44 | this.webBrowser1.Url = new System.Uri("", System.UriKind.Relative);
45 | //
46 | // buttonDownload
47 | //
48 | this.buttonDownload.Location = new System.Drawing.Point(173, 382);
49 | this.buttonDownload.Name = "buttonDownload";
50 | this.buttonDownload.Size = new System.Drawing.Size(445, 32);
51 | this.buttonDownload.TabIndex = 1;
52 | this.buttonDownload.Text = "Download and install now!";
53 | this.buttonDownload.UseVisualStyleBackColor = true;
54 | this.buttonDownload.Click += new System.EventHandler(this.buttonDownload_Click);
55 | //
56 | // buttonCancel
57 | //
58 | this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
59 | this.buttonCancel.Location = new System.Drawing.Point(12, 382);
60 | this.buttonCancel.Name = "buttonCancel";
61 | this.buttonCancel.Size = new System.Drawing.Size(155, 32);
62 | this.buttonCancel.TabIndex = 2;
63 | this.buttonCancel.Text = "Ignore this update";
64 | this.buttonCancel.UseVisualStyleBackColor = true;
65 | //
66 | // UpdateAvailableDialog
67 | //
68 | this.AcceptButton = this.buttonDownload;
69 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
70 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
71 | this.CancelButton = this.buttonCancel;
72 | this.ClientSize = new System.Drawing.Size(630, 426);
73 | this.Controls.Add(this.buttonCancel);
74 | this.Controls.Add(this.buttonDownload);
75 | this.Controls.Add(this.webBrowser1);
76 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
77 | this.Icon = global::puush.Properties.Resources.iconbundle;
78 | this.MaximizeBox = false;
79 | this.MinimizeBox = false;
80 | this.Name = "UpdateAvailableDialog";
81 | this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
82 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
83 | this.Text = "Update Available!";
84 | this.ResumeLayout(false);
85 |
86 | }
87 |
88 | #endregion
89 |
90 | private System.Windows.Forms.WebBrowser webBrowser1;
91 | private System.Windows.Forms.Button buttonDownload;
92 | private System.Windows.Forms.Button buttonCancel;
93 | }
94 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/UrlParser.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Globalization;
5 |
6 | internal class UrlParser
7 | {
8 | private string absolutePath;
9 | private string absoluteUri;
10 | private string host;
11 | private string password;
12 | private int port;
13 | private string scheme;
14 | private Uri url;
15 | private string userName;
16 |
17 | private void InternalParse(Uri url)
18 | {
19 | this.url = url;
20 | this.host = string.Empty;
21 | this.port = 80;
22 | this.absolutePath = string.Empty;
23 | this.absoluteUri = string.Empty;
24 | this.userName = string.Empty;
25 | this.password = string.Empty;
26 | this.scheme = string.Empty;
27 | if (this.url != null)
28 | {
29 | this.host = this.url.Host;
30 | this.port = this.url.Port;
31 | this.absolutePath = this.url.PathAndQuery;
32 | this.absoluteUri = this.url.AbsoluteUri;
33 | this.scheme = this.url.Scheme;
34 | int index = this.url.UserInfo.IndexOf(':');
35 | if (index > 0)
36 | {
37 | this.userName = this.url.UserInfo.Substring(0, index);
38 | this.password = this.url.UserInfo.Substring(index + 1);
39 | }
40 | else
41 | {
42 | this.userName = this.url.UserInfo;
43 | }
44 | }
45 | }
46 |
47 | public void Parse(string url)
48 | {
49 | try
50 | {
51 | this.InternalParse(new Uri(url));
52 | }
53 | catch (UriFormatException)
54 | {
55 | if (url != "*")
56 | {
57 | if (StringUtils.IsEmpty(url) || (url.ToLower(CultureInfo.InvariantCulture).IndexOf(Uri.UriSchemeHttp) >= 0))
58 | {
59 | throw;
60 | }
61 | this.InternalParse(new Uri(Uri.UriSchemeHttp + Uri.SchemeDelimiter + url));
62 | }
63 | else
64 | {
65 | this.InternalParse(null);
66 | this.host = "*";
67 | this.port = 80;
68 | this.absolutePath = "/";
69 | this.absoluteUri = "http://*/";
70 | this.userName = string.Empty;
71 | this.password = string.Empty;
72 | this.scheme = Uri.UriSchemeHttp;
73 | }
74 | }
75 | }
76 |
77 | public void Parse(Uri baseUri, string relativeUri)
78 | {
79 | this.InternalParse(new Uri(baseUri, relativeUri));
80 | }
81 |
82 | public string AbsolutePath
83 | {
84 | get
85 | {
86 | return this.absolutePath;
87 | }
88 | }
89 |
90 | public string AbsoluteUri
91 | {
92 | get
93 | {
94 | return this.absoluteUri;
95 | }
96 | }
97 |
98 | public string Host
99 | {
100 | get
101 | {
102 | return this.host;
103 | }
104 | }
105 |
106 | public string Password
107 | {
108 | get
109 | {
110 | return this.password;
111 | }
112 | }
113 |
114 | public int Port
115 | {
116 | get
117 | {
118 | return this.port;
119 | }
120 | }
121 |
122 | public string Scheme
123 | {
124 | get
125 | {
126 | return this.scheme;
127 | }
128 | }
129 |
130 | public Uri Url
131 | {
132 | get
133 | {
134 | return this.url;
135 | }
136 | }
137 |
138 | public string UserName
139 | {
140 | get
141 | {
142 | return this.userName;
143 | }
144 | }
145 | }
146 | }
147 |
148 |
--------------------------------------------------------------------------------
/Libraries/Hooking/HookManager.Structures.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace Gma.UserActivityMonitor {
4 |
5 | public static partial class HookManager {
6 | ///
7 | /// The Point structure defines the X- and Y- coordinates of a point.
8 | ///
9 | ///
10 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/rectangl_0tiq.asp
11 | ///
12 | [StructLayout(LayoutKind.Sequential)]
13 | private struct Point {
14 | ///
15 | /// Specifies the X-coordinate of the point.
16 | ///
17 | public int X;
18 | ///
19 | /// Specifies the Y-coordinate of the point.
20 | ///
21 | public int Y;
22 | }
23 |
24 | ///
25 | /// The MSLLHOOKSTRUCT structure contains information about a low-level keyboard input event.
26 | ///
27 | [StructLayout(LayoutKind.Sequential)]
28 | private struct MouseLLHookStruct {
29 | ///
30 | /// Specifies a Point structure that contains the X- and Y-coordinates of the cursor, in screen coordinates.
31 | ///
32 | public Point Point;
33 | ///
34 | /// If the message is WM_MOUSEWHEEL, the high-order word of this member is the wheel delta.
35 | /// The low-order word is reserved. A positive value indicates that the wheel was rotated forward,
36 | /// away from the user; a negative value indicates that the wheel was rotated backward, toward the user.
37 | /// One wheel click is defined as WHEEL_DELTA, which is 120.
38 | ///If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP,
39 | /// or WM_NCXBUTTONDBLCLK, the high-order word specifies which X button was pressed or released,
40 | /// and the low-order word is reserved. This value can be one or more of the following values. Otherwise, MouseData is not used.
41 | ///XBUTTON1
42 | ///The first X button was pressed or released.
43 | ///XBUTTON2
44 | ///The second X button was pressed or released.
45 | ///
46 | public int MouseData;
47 | ///
48 | /// Specifies the event-injected flag. An application can use the following value to test the mouse Flags. Value Purpose
49 | ///LLMHF_INJECTED Test the event-injected flag.
50 | ///0
51 | ///Specifies whether the event was injected. The value is 1 if the event was injected; otherwise, it is 0.
52 | ///1-15
53 | ///Reserved.
54 | ///
55 | public int Flags;
56 | ///
57 | /// Specifies the Time stamp for this message.
58 | ///
59 | public int Time;
60 | ///
61 | /// Specifies extra information associated with the message.
62 | ///
63 | public int ExtraInfo;
64 | }
65 |
66 | ///
67 | /// The KBDLLHOOKSTRUCT structure contains information about a low-level keyboard input event.
68 | ///
69 | ///
70 | /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/hooks/hookreference/hookstructures/cwpstruct.asp
71 | ///
72 | [StructLayout(LayoutKind.Sequential)]
73 | private struct KeyboardHookStruct
74 | {
75 | ///
76 | /// Specifies a virtual-key code. The code must be a value in the range 1 to 254.
77 | ///
78 | public int VirtualKeyCode;
79 | ///
80 | /// Specifies a hardware scan code for the key.
81 | ///
82 | public int ScanCode;
83 | ///
84 | /// Specifies the extended-key flag, event-injected flag, context code, and transition-state flag.
85 | ///
86 | public int Flags;
87 | ///
88 | /// Specifies the Time stamp for this message.
89 | ///
90 | public int Time;
91 | ///
92 | /// Specifies extra information associated with the message.
93 | ///
94 | public int ExtraInfo;
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/ScreenshotCapture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 | using System.Drawing;
6 | using System.IO;
7 | using System.Drawing.Imaging;
8 | using osu_common.Libraries.NetLib;
9 | using System.Runtime.InteropServices;
10 | using System.Diagnostics;
11 | using puush.Libraries;
12 | using System.Threading;
13 |
14 | namespace puush
15 | {
16 | public static class ScreenshotCapture
17 | {
18 | [DllImport("user32.dll")]
19 | [return: MarshalAs(UnmanagedType.Bool)]
20 | static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
21 |
22 | [StructLayout(LayoutKind.Sequential)]
23 | public struct RECT
24 | {
25 | public int Left;
26 | public int Top;
27 | public int Right;
28 | public int Bottom;
29 | }
30 |
31 | internal static void RunWindow()
32 | {
33 | if (!puush.EnsureLogin()) return;
34 |
35 | RECT rct;
36 |
37 | if (GetWindowRect(puush.LastForegroundWindow, out rct))
38 | Run(rct.Left, rct.Right, rct.Top, rct.Bottom);
39 | }
40 |
41 | internal static void Run()
42 | {
43 | if (!puush.EnsureLogin()) return;
44 |
45 | int? minX = null;
46 | int? minY = null;
47 | int? maxX = null;
48 | int? maxY = null;
49 |
50 | List screens = new List();
51 |
52 | switch ((FullscreenCaptureMode)puush.config.GetValue("FullscreenMode", 0))
53 | {
54 | case FullscreenCaptureMode.AllScreens:
55 | screens.AddRange(Screen.AllScreens);
56 | break;
57 | case FullscreenCaptureMode.Mouse:
58 | foreach (Screen s in Screen.AllScreens)
59 | {
60 | if (s.Bounds.Contains(Cursor.Position))
61 | screens.Add(s);
62 | }
63 | break;
64 | case FullscreenCaptureMode.Primary:
65 | screens.Add(Screen.PrimaryScreen);
66 | break;
67 | }
68 |
69 | //first find the full range of available bounds...
70 | foreach (Screen s in screens)
71 | {
72 | if (minX == null || s.Bounds.Left < minX) minX = s.Bounds.Left;
73 | if (maxX == null || s.Bounds.Right > maxX) maxX = s.Bounds.Right;
74 | if (minY == null || s.Bounds.Top < minY) minY = s.Bounds.Top;
75 | if (maxY == null || s.Bounds.Bottom > maxY) maxY = s.Bounds.Bottom;
76 | }
77 |
78 | Run(minX.Value, maxX.Value, minY.Value, maxY.Value);
79 | }
80 |
81 | [DllImport("dwmapi.dll", EntryPoint = "DwmIsCompositionEnabled")]
82 | public static extern int DwmIsCompositionEnabled(out bool enabled);
83 |
84 | internal static unsafe void Run(int minX, int maxX, int minY, int maxY)
85 | {
86 | try
87 | {
88 | int width = maxX - minX;
89 | int height = maxY - minY;
90 |
91 | RECT rct;
92 | if (GetWindowRect(puush.LastForegroundWindow, out rct))
93 | {
94 | Rectangle screen = Screen.PrimaryScreen.Bounds;
95 |
96 | /*if (rct.Left == 0 && rct.Top == 0 && rct.Right == screen.Width && rct.Bottom == screen.Height)
97 | {
98 | SendKeys.SendWait("{PRTSC}");
99 | Thread.Sleep(250);
100 | MainForm.Instance.UploadClipboard("ss");
101 | return;
102 | }*/
103 | }
104 |
105 | using (Bitmap b = new Bitmap(width, height, PixelFormat.Format24bppRgb))
106 | using (Graphics g = Graphics.FromImage(b))
107 | {
108 | try
109 | {
110 | bool aero;
111 | DwmIsCompositionEnabled(out aero);
112 | if (!aero) Thread.Sleep(200);
113 | }
114 | catch { }
115 |
116 | g.CopyFromScreen(minX, minY, 0, 0, new Size(width, height), CopyPixelOperation.SourceCopy);
117 |
118 | FileUpload.UploadImage(b, "ss");
119 | }
120 | }
121 | catch (Exception e)
122 | {
123 | TopMostMessageBox.Show("Failed to take screenshot. Please report this if it should have worked!\n" + e.ToString(), "puush", MessageBoxButtons.OK, MessageBoxIcon.Error);
124 | }
125 | }
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/HistoryItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 | using System.Diagnostics;
6 | using System.Drawing;
7 | using puush.Libraries;
8 | using System.IO;
9 | using osu_common.Libraries.NetLib;
10 |
11 | namespace puush
12 | {
13 | internal class HistoryItem : ToolStripMenuItem
14 | {
15 | internal int id;
16 | internal string date;
17 | internal string url;
18 | internal string filename;
19 | internal int viewCount;
20 |
21 | bool thumbnailLoaded = false;
22 |
23 |
24 | public HistoryItem(int id, string date, string url, string filename, int viewCount)
25 | : base(filename)
26 | {
27 | DropDownOpening += HistoryItem_DropDownOpening;
28 | this.id = id;
29 | this.date = date;
30 | this.url = url;
31 | this.filename = filename;
32 | this.viewCount = viewCount;
33 |
34 | string extension = Path.GetExtension(filename);
35 |
36 | try
37 | {
38 | using (Icon icon = Icons.IconFromExtensionShell(extension, Icons.SystemIconSize.Small))
39 | {
40 | if (icon != null)
41 | {
42 | Image = icon.ToBitmap();
43 | Icons.DestroyIcon(icon.Handle);
44 | }
45 | }
46 | }
47 | catch
48 | {
49 | //this could fail, but in this case we just display no icon at all.
50 | }
51 |
52 | DropDownItems.Add("Uploaded: " + date);
53 | DropDownItems[DropDownItems.Count - 1].Enabled = false;
54 |
55 | DropDownItems.Add("Views: " + viewCount);
56 | DropDownItems[DropDownItems.Count - 1].Enabled = false;
57 |
58 | DropDownItems.Add("Open in browser", null, OpenURL);
59 | DropDownItems.Add("Copy link to clipboard", null, CopyToClipboard);
60 | DropDownItems.Add(new ToolStripSeparator());
61 | DropDownItems.Add("Delete", null, Delete);
62 | }
63 |
64 | protected override void Dispose(bool disposing)
65 | {
66 | if (Image != null)
67 | Image.Dispose();
68 |
69 | base.Dispose(disposing);
70 | }
71 |
72 | void HistoryItem_DropDownOpening(object sender, EventArgs e)
73 | {
74 | if (!thumbnailLoaded)
75 | {
76 | thumbnailLoaded = true;
77 |
78 | FormDataNetRequest request = new FormDataNetRequest(puush.getApiUrl("thumb"));
79 | request.request.Items.AddFormField("k", puush.config.GetValue("key", ""));
80 | request.request.Items.AddFormField("i", id.ToString());
81 | request.onFinish += new FormDataNetRequest.RequestCompleteHandler(request_onFinish);
82 |
83 | NetManager.AddRequest(request);
84 | }
85 | }
86 |
87 | void request_onFinish(byte[] thumb, Exception e)
88 | {
89 | if (thumb.Length > 0)
90 | {
91 | MainForm.invokeMeSome(delegate
92 | {
93 | try
94 | {
95 | Image image = Image.FromStream(new MemoryStream(thumb), false, false);
96 |
97 | ToolStripItemThumbnail item = new ToolStripItemThumbnail(image, Width);
98 | item.Click += OpenURL;
99 |
100 | DropDownItems.Insert(0, item);
101 | }
102 | catch
103 | {
104 | //getting here means the image we downloaded is likely no an image or corrupt. ignore.
105 | }
106 | });
107 | }
108 | }
109 |
110 | public void OpenURL(object sender, EventArgs args)
111 | {
112 | Process.Start(url);
113 | }
114 |
115 | public void CopyToClipboard(object sender, EventArgs args)
116 | {
117 | try
118 | {
119 | Clipboard.SetText(url);
120 | }
121 | catch
122 | {
123 | TopMostMessageBox.Show("Failed to copy URL to clipboard. Please report this if you believe it shouldn't have failed!", "puush", MessageBoxButtons.OK, MessageBoxIcon.Error);
124 | }
125 | }
126 |
127 | public void Delete(object sender, EventArgs args)
128 | {
129 | FormNetRequest req = new FormNetRequest(puush.getApiUrl("del"));
130 | req.request.Items.AddFormField("k", puush.config.GetValue("key", ""));
131 | req.request.Items.AddFormField("i", id.ToString());
132 | req.request.Items.AddFormField("z", "poop");
133 | req.onFinish += HistoryManager.historyRetrieval_onFinish;
134 |
135 | NetManager.AddRequest(req);
136 | }
137 |
138 | }
139 |
140 |
141 | }
142 |
--------------------------------------------------------------------------------
/Libraries/NetLib/HttpRequestItemList.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Collections;
5 | using System.ComponentModel;
6 | using System.Globalization;
7 | using System.Reflection;
8 |
9 | [ListBindable(BindableSupport.No), Editor("Design.HttpRequestItemsEditor, Design", "System.Drawing.Design.UITypeEditor, System.Drawing")]
10 | public class HttpRequestItemList : CollectionBase
11 | {
12 | private HttpRequest owner;
13 |
14 | public HttpRequestItemList(HttpRequest owner)
15 | {
16 | this.owner = owner;
17 | }
18 |
19 | public void Add(HttpRequestItem item)
20 | {
21 | base.List.Add(item);
22 | }
23 |
24 | public BinaryRequestItem AddBinaryData()
25 | {
26 | BinaryRequestItem item = new BinaryRequestItem();
27 | this.Add(item);
28 | return item;
29 | }
30 |
31 | public FormFieldRequestItem AddFormField(string fieldName, string fieldValue)
32 | {
33 | FormFieldRequestItem item = new FormFieldRequestItem(fieldName, fieldValue);
34 | this.Add(item);
35 | return item;
36 | }
37 |
38 | public void AddRange(HttpRequestItem[] items)
39 | {
40 | foreach (HttpRequestItem item in items)
41 | {
42 | this.Add(item);
43 | }
44 | }
45 |
46 | public SubmitFileRequestItem AddSubmitFile(string fileName, string fieldName)
47 | {
48 | SubmitFileRequestItem item = new SubmitFileRequestItem(fileName, fieldName);
49 | this.Add(item);
50 | return item;
51 | }
52 |
53 | public TextRequestItem AddTextData(string textData)
54 | {
55 | TextRequestItem item = new TextRequestItem(textData);
56 | this.Add(item);
57 | return item;
58 | }
59 |
60 | public FormFieldRequestItem FormFieldByName(string fieldName)
61 | {
62 | foreach (HttpRequestItem item in this)
63 | {
64 | if ((item is FormFieldRequestItem) && (string.Compare(((FormFieldRequestItem) item).FieldName, fieldName, true, CultureInfo.InvariantCulture) == 0))
65 | {
66 | return (FormFieldRequestItem) item;
67 | }
68 | }
69 | return null;
70 | }
71 |
72 | public void Move(int curIndex, int newIndex)
73 | {
74 | if (curIndex != newIndex)
75 | {
76 | object obj2 = base.InnerList[curIndex];
77 | if (newIndex < curIndex)
78 | {
79 | base.InnerList.RemoveAt(curIndex);
80 | base.InnerList.Insert(newIndex, obj2);
81 | }
82 | else
83 | {
84 | base.InnerList.Insert(newIndex, obj2);
85 | base.InnerList.RemoveAt(curIndex);
86 | }
87 | this.Update();
88 | }
89 | }
90 |
91 | protected override void OnClear()
92 | {
93 | base.OnClear();
94 | foreach (HttpRequestItem item in base.InnerList)
95 | {
96 | item.owner_ = null;
97 | }
98 | }
99 |
100 | protected override void OnClearComplete()
101 | {
102 | base.OnClearComplete();
103 | if (this.Owner != null)
104 | {
105 | this.Owner.UpdateContentType();
106 | }
107 | this.Update();
108 | }
109 |
110 | protected override void OnInsertComplete(int index, object theValue)
111 | {
112 | base.OnInsertComplete(index, theValue);
113 | ((HttpRequestItem) theValue).owner_ = this.Owner;
114 | if (this.Owner != null)
115 | {
116 | this.Owner.UpdateContentType();
117 | }
118 | this.Update();
119 | }
120 |
121 | protected override void OnRemoveComplete(int index, object theValue)
122 | {
123 | base.OnRemoveComplete(index, theValue);
124 | ((HttpRequestItem) theValue).owner_ = null;
125 | if (this.Owner != null)
126 | {
127 | this.Owner.UpdateContentType();
128 | }
129 | this.Update();
130 | }
131 |
132 | public void Remove(HttpRequestItem item)
133 | {
134 | base.List.Remove(item);
135 | }
136 |
137 | public void Update()
138 | {
139 | if (this.Owner != null)
140 | {
141 | this.Owner.Update();
142 | }
143 | }
144 |
145 | public HttpRequestItem this[int index]
146 | {
147 | get
148 | {
149 | return (HttpRequestItem) base.InnerList[index];
150 | }
151 | }
152 |
153 | public HttpRequest Owner
154 | {
155 | get
156 | {
157 | return this.owner;
158 | }
159 | }
160 | }
161 | }
162 |
163 |
--------------------------------------------------------------------------------
/ContextMenuHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Text;
5 | using Microsoft.Win32;
6 |
7 | namespace puush
8 | {
9 | class ContextMenuHandler
10 | {
11 | internal const string MenuName = "*\\shell\\puush";
12 | internal const string Command = "*\\shell\\puush\\command";
13 |
14 | internal static bool Install()
15 | {
16 | RegistryKey regmenu = null;
17 | RegistryKey regcmd = null;
18 |
19 | try
20 | {
21 | regmenu = Registry.ClassesRoot.OpenSubKey(MenuName);
22 | if (regmenu != null) return true;
23 | regmenu = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Classes").OpenSubKey("*").OpenSubKey(MenuName);
24 | if (regmenu != null) return true;
25 |
26 | try
27 | {
28 | regmenu = Registry.ClassesRoot.CreateSubKey(MenuName);
29 | }
30 | catch
31 | {
32 | regmenu = Registry.CurrentUser.OpenSubKey("Software").OpenSubKey("Classes").OpenSubKey("*").CreateSubKey(MenuName);
33 | }
34 |
35 | if (regmenu != null)
36 | regmenu.SetValue("", "puush");
37 |
38 | regcmd = Registry.ClassesRoot.CreateSubKey(Command);
39 | if (regcmd != null)
40 | {
41 | string cmdLine = Environment.CommandLine;
42 | string[] parts = cmdLine.Split(' ');
43 |
44 | cmdLine = "";
45 | foreach (string part in parts)
46 | {
47 | if (part.StartsWith("-"))
48 | break;
49 | cmdLine += " " + part;
50 | }
51 |
52 | cmdLine = cmdLine.Trim();
53 |
54 | regcmd.SetValue("", cmdLine + " -upload %1");
55 | }
56 | }
57 | catch (Exception ex)
58 | {
59 | if (!puush.IsRunningElevated && !puush.config.GetValue("contextmenuattempted", false))
60 | {
61 | ProcessStartInfo startInfo = new ProcessStartInfo();
62 | startInfo.UseShellExecute = true;
63 | startInfo.WorkingDirectory = Environment.CurrentDirectory;
64 | startInfo.FileName = "puush.exe";
65 | startInfo.Arguments = "-setPermissions";
66 | startInfo.Verb = "runas";
67 |
68 | try
69 | {
70 | puush.config.SetValue("contextmenuattempted", true);
71 | puush.config.SaveConfig();
72 |
73 | Process pr = Process.Start(startInfo);
74 | if (pr != null) pr.WaitForExit(8000);
75 | return true;
76 | }
77 | catch (System.ComponentModel.Win32Exception)
78 | {
79 | return false;
80 | }
81 | }
82 | }
83 | finally
84 | {
85 | if (regmenu != null)
86 | regmenu.Close();
87 | if (regcmd != null)
88 | regcmd.Close();
89 | }
90 |
91 | return true;
92 | }
93 |
94 | internal static void Remove()
95 | {
96 | try
97 | {
98 | RegistryKey reg = Registry.ClassesRoot.OpenSubKey(Command);
99 | if (reg != null)
100 | {
101 | reg.Close();
102 | Registry.ClassesRoot.DeleteSubKey(Command);
103 | }
104 | reg = Registry.ClassesRoot.OpenSubKey(MenuName);
105 | if (reg != null)
106 | {
107 | reg.Close();
108 | Registry.ClassesRoot.DeleteSubKey(MenuName);
109 | }
110 | }
111 | catch (Exception ex)
112 | {
113 | if (!puush.IsRunningElevated)
114 | {
115 | ProcessStartInfo startInfo = new ProcessStartInfo();
116 | startInfo.UseShellExecute = true;
117 | startInfo.WorkingDirectory = Environment.CurrentDirectory;
118 | startInfo.FileName = "puush.exe";
119 | startInfo.Arguments = "-removeContext";
120 | startInfo.Verb = "runas";
121 |
122 | try
123 | {
124 | Process pr = Process.Start(startInfo);
125 | if (pr != null) pr.WaitForExit(8000);
126 | }
127 | catch (System.ComponentModel.Win32Exception)
128 | {
129 | }
130 | }
131 | }
132 | }
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/Libraries/NetLib/NetworkStream.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Net;
4 | using System.Net.Sockets;
5 |
6 | namespace osu_common.Libraries.NetLib
7 | {
8 | public class NetworkStream
9 | {
10 | internal Connection connection;
11 | private IPAddress ip;
12 | private int listenPort;
13 | private NetworkStreamAction nextAction;
14 | private string peerIP;
15 | private string peerName;
16 | private int port;
17 |
18 | public Connection Connection
19 | {
20 | get { return connection; }
21 | }
22 |
23 | public bool HasReadData { get; set; }
24 |
25 | public IPAddress IP
26 | {
27 | get { return ip; }
28 | }
29 |
30 | public int ListenPort
31 | {
32 | get { return listenPort; }
33 | }
34 |
35 | public NetworkStreamAction NextAction
36 | {
37 | get { return nextAction; }
38 | }
39 |
40 | public string PeerIP
41 | {
42 | get { return peerIP; }
43 | }
44 |
45 | public string PeerName
46 | {
47 | get { return peerName; }
48 | }
49 |
50 | public int Port
51 | {
52 | get { return port; }
53 | }
54 |
55 | public virtual void Accept()
56 | {
57 | ClearNextAction();
58 | Connection.NetworkStreamAccept();
59 | try
60 | {
61 | IPHostEntry hostByAddress = Dns.GetHostEntry(((IPEndPoint) Connection.Socket.RemoteEndPoint).Address);
62 | if (hostByAddress.AddressList.Length > 0)
63 | {
64 | peerIP = hostByAddress.AddressList[0].ToString();
65 | peerName = hostByAddress.HostName;
66 | if (StringUtils.IsEmpty(peerName))
67 | {
68 | peerName = peerIP;
69 | }
70 | peerName = peerName.Trim();
71 | }
72 | }
73 | catch (SocketException)
74 | {
75 | peerIP = string.Empty;
76 | peerName = string.Empty;
77 | }
78 | }
79 |
80 | public void ClearNextAction()
81 | {
82 | nextAction = NetworkStreamAction.None;
83 | }
84 |
85 | public virtual void Close(bool notifyPeer)
86 | {
87 | ClearNextAction();
88 | }
89 |
90 | public virtual bool Connect(IPAddress ip, int port)
91 | {
92 | ClearNextAction();
93 | this.ip = ip;
94 | this.port = port;
95 | return Connection.NetworkStreamConnect(ip, port);
96 | }
97 |
98 | public virtual void CopyTo(NetworkStream destination)
99 | {
100 | destination.listenPort = ListenPort;
101 | destination.peerName = PeerName;
102 | destination.peerIP = PeerIP;
103 | destination.ip = IP;
104 | destination.port = Port;
105 | }
106 |
107 | public virtual int GetBatchSize()
108 | {
109 | if (Connection.BatchSize < 1)
110 | {
111 | throw new SocketError("Invalid Batch Size", -1);
112 | }
113 | if ((Connection.BytesToProceed > -1L) &&
114 | ((Connection.BytesToProceed - Connection.bytesProceed) < Connection.BatchSize))
115 | {
116 | return (int) (Connection.BytesToProceed - Connection.bytesProceed);
117 | }
118 | return Connection.BatchSize;
119 | }
120 |
121 | public virtual void Listen(int port)
122 | {
123 | ClearNextAction();
124 | ip = null;
125 | this.port = port;
126 | Connection.NetworkStreamListen(port);
127 | listenPort = ((IPEndPoint) Connection.Socket.LocalEndPoint).Port;
128 | }
129 |
130 | public virtual void OpenClientSession()
131 | {
132 | }
133 |
134 | public virtual void OpenServerSession()
135 | {
136 | }
137 |
138 | public virtual bool Read(Stream data)
139 | {
140 | ClearNextAction();
141 | return Connection.NetworkStreamRead(data);
142 | }
143 |
144 | public void SetNextAction(NetworkStreamAction action)
145 | {
146 | if (nextAction == NetworkStreamAction.None)
147 | {
148 | nextAction = action;
149 | }
150 | }
151 |
152 | protected internal virtual void StreamReady()
153 | {
154 | Connection.OnReady(new EventArgs());
155 | }
156 |
157 | protected internal virtual void UpdateProgress(int bytesProceed)
158 | {
159 | Connection connection = Connection;
160 | connection.bytesProceed += bytesProceed;
161 | Connection connection2 = Connection;
162 | connection2.totalBytesProceed += bytesProceed;
163 | Connection.OnProgress(new SocketProgressEventArgs(Connection.totalBytesProceed, Connection.totalBytes));
164 | }
165 |
166 | public virtual bool Write(Stream data)
167 | {
168 | ClearNextAction();
169 | return ((data.Length == 0L) || Connection.NetworkStreamWrite(data));
170 | }
171 | }
172 | }
--------------------------------------------------------------------------------
/Libraries/pConfigManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 |
6 | namespace osu_common.Helpers
7 | {
8 | ///
9 | /// Simple Configurtion Manager
10 | ///
11 | public class pConfigManager : IDisposable
12 | {
13 | private readonly Dictionary entriesRaw = new Dictionary();
14 | private readonly Dictionary entriesParsed = new Dictionary();
15 | private string configFilename;
16 | private bool dirty;
17 | public bool WriteOnChange { get; set; }
18 |
19 | ///
20 | /// Initializes a new instance of the class with a default filename (same as the host process).
21 | ///
22 | public pConfigManager()
23 | {
24 | LoadConfig();
25 | }
26 |
27 | ///
28 | /// Initializes a new instance of the class with a custom filename.
29 | ///
30 | /// The filename.
31 | public pConfigManager(string filename)
32 | {
33 | LoadConfig(filename);
34 | }
35 |
36 | ~pConfigManager()
37 | {
38 | Dispose();
39 | }
40 |
41 | public void Dispose()
42 | {
43 | if (dirty) SaveConfig();
44 | }
45 |
46 | public T GetValue(string key, T defaultValue)
47 | {
48 | object obj;
49 |
50 | if (entriesParsed.TryGetValue(key,out obj))
51 | return (T)obj;
52 |
53 | string raw;
54 | if (!entriesRaw.TryGetValue(key, out raw))
55 | {
56 | //If we don't have a value, we should set the default to be written back to the config file.
57 | SetValue(key, defaultValue);
58 | return defaultValue;
59 | }
60 |
61 | string ty = typeof (T).Name;
62 |
63 | switch (ty)
64 | {
65 | case "Boolean":
66 | obj = raw[0] == '1';
67 | break;
68 | case "Int32":
69 | obj = Int32.Parse(raw);
70 | break;
71 | case "Int64":
72 | obj = Int64.Parse(raw);
73 | break;
74 | case "String":
75 | obj = raw;
76 | break;
77 | }
78 |
79 | entriesParsed[key] = obj;
80 | entriesRaw[key] = raw;
81 |
82 | return (T) obj;
83 | }
84 |
85 | public void SetValue(string key, T value)
86 | {
87 | switch (typeof(T).Name)
88 | {
89 | default:
90 | if (value == null)
91 | entriesRaw[key] = null;
92 | else
93 | entriesRaw[key] = value.ToString();
94 | break;
95 | case "Boolean":
96 | entriesRaw[key] = value.ToString() == "True" ? "1" : "0";
97 | break;
98 | }
99 |
100 | entriesParsed[key] = value;
101 |
102 | dirty = true;
103 |
104 | if (WriteOnChange) SaveConfig();
105 |
106 | }
107 |
108 | public void LoadConfig()
109 | {
110 | LoadConfig("osu!Bancho.cfg");
111 | }
112 |
113 | public void LoadConfig(string configName)
114 | {
115 | entriesRaw.Clear();
116 | entriesParsed.Clear();
117 |
118 | configFilename = configName;
119 | ReadConfigFile(configName);
120 | }
121 |
122 | private void ReadConfigFile(string filename)
123 | {
124 | if (!File.Exists(filename)) return;
125 |
126 | //a failure shouldn't mean a crash.
127 | try
128 | {
129 | using (StreamReader r = File.OpenText(filename))
130 | while (!r.EndOfStream)
131 | {
132 | string line = r.ReadLine();
133 | if (line.Length < 2)
134 | continue;
135 | int equals = line.IndexOf('=');
136 | string key = line.Remove(equals).Trim();
137 | string value = line.Substring(equals + 1).Trim();
138 | entriesRaw[key] = value;
139 | }
140 | }
141 | catch { }
142 | }
143 |
144 | public void SaveConfig()
145 | {
146 | if (configFilename == null)
147 | throw new Exception("Not initialized.");
148 | WriteConfigFile(configFilename);
149 |
150 | dirty = false;
151 | }
152 |
153 | private bool WriteConfigFile(string filename)
154 | {
155 | try
156 | {
157 | using (StreamWriter w = new StreamWriter(filename, false))
158 | foreach (KeyValuePair p in entriesRaw)
159 | w.WriteLine("{0} = {1}", p.Key, p.Value);
160 | }
161 | catch
162 | {
163 | return false;
164 | }
165 | return true;
166 | }
167 | }
168 | }
--------------------------------------------------------------------------------
/Libraries/NetLib/CookieList.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Collections;
5 | using System.Collections.Specialized;
6 | using System.Globalization;
7 | using System.Reflection;
8 |
9 | public class CookieList : CollectionBase
10 | {
11 | public void Add(CookieItem item)
12 | {
13 | base.List.Add(item);
14 | }
15 |
16 | public CookieItem Add(string name, string theValue)
17 | {
18 | CookieItem item = new CookieItem(name, theValue);
19 | this.Add(item);
20 | return item;
21 | }
22 |
23 | protected virtual string BuildRequestCookie(CookieItem cookie)
24 | {
25 | return (cookie.Name + "=" + cookie.Value);
26 | }
27 |
28 | private string GetExpires(string cookieData)
29 | {
30 | int index = cookieData.ToLower(CultureInfo.InvariantCulture).IndexOf("expires=");
31 | if (index > -1)
32 | {
33 | return HeaderFieldList.GetHeaderFieldValueItem(cookieData.Substring(index + "expires=".Length).Replace(",", "=="), string.Empty).Replace("==", ",");
34 | }
35 | return string.Empty;
36 | }
37 |
38 | public void GetResponseCookies(StringCollection responseHeader)
39 | {
40 | base.Clear();
41 | HeaderFieldList fieldList = new HeaderFieldList();
42 | HeaderFieldList.GetHeaderFieldList(0, responseHeader, fieldList);
43 | if (!StringUtils.IsEmpty(HeaderFieldList.GetHeaderFieldValue(responseHeader, fieldList, "set-cookie2")))
44 | {
45 | this.ProcessCookies(responseHeader, fieldList, "set-cookie2");
46 | }
47 | else
48 | {
49 | this.ProcessCookies(responseHeader, fieldList, "set-cookie");
50 | }
51 | }
52 |
53 | protected virtual void ParseResponseCookie(string cookieData)
54 | {
55 | if (!StringUtils.IsEmpty(cookieData))
56 | {
57 | string str = cookieData;
58 | string headerFieldValueItem = "";
59 | int index = cookieData.IndexOf("=");
60 | if (index > -1)
61 | {
62 | str = cookieData.Substring(0, index);
63 | headerFieldValueItem = HeaderFieldList.GetHeaderFieldValueItem(cookieData, str.ToLower(CultureInfo.InvariantCulture) + "=");
64 | }
65 | if (this[str] == null)
66 | {
67 | CookieItem item = new CookieItem();
68 | this.Add(item);
69 | item.Name = str;
70 | item.Value = headerFieldValueItem;
71 | item.Expires = this.GetExpires(cookieData);
72 | item.Domain = HeaderFieldList.GetHeaderFieldValueItem(cookieData, "domain=");
73 | item.Path = HeaderFieldList.GetHeaderFieldValueItem(cookieData, "path=");
74 | item.Secure = cookieData.ToLower(CultureInfo.InvariantCulture).IndexOf("secure") > -1;
75 | item.CookieData = cookieData;
76 | }
77 | }
78 | }
79 |
80 | private void ProcessCookies(StringCollection responseHeader, HeaderFieldList fieldList, string fieldName)
81 | {
82 | foreach (HeaderField field in fieldList)
83 | {
84 | if (string.Compare(field.Name, fieldName, true, CultureInfo.InvariantCulture) == 0)
85 | {
86 | this.ParseResponseCookie(HeaderFieldList.GetHeaderFieldValue(responseHeader, field));
87 | }
88 | }
89 | }
90 |
91 | public void Remove(CookieItem item)
92 | {
93 | base.List.Remove(item);
94 | }
95 |
96 | private void RemoveCookies(StringCollection requestHeader)
97 | {
98 | HeaderFieldList fieldList = new HeaderFieldList();
99 | HeaderFieldList.GetHeaderFieldList(0, requestHeader, fieldList);
100 | for (int i = fieldList.Count - 1; i >= 0; i--)
101 | {
102 | HeaderField field = fieldList[i];
103 | if (string.Compare(field.Name, "cookie", true, CultureInfo.InvariantCulture) == 0)
104 | {
105 | HeaderFieldList.RemoveHeaderField(requestHeader, fieldList, field);
106 | }
107 | }
108 | }
109 |
110 | public void SetRequestCookies(StringCollection requestHeader)
111 | {
112 | this.RemoveCookies(requestHeader);
113 | string str = "";
114 | foreach (CookieItem item in this)
115 | {
116 | str = str + this.BuildRequestCookie(item) + "; ";
117 | }
118 | if (!StringUtils.IsEmpty(str))
119 | {
120 | str = str.Substring(0, str.Length - "; ".Length);
121 | }
122 | HeaderFieldList.AddHeaderField(requestHeader, "Cookie", str);
123 | }
124 |
125 | public CookieItem this[string name]
126 | {
127 | get
128 | {
129 | foreach (CookieItem item in this)
130 | {
131 | if (string.Compare(item.Name, name, true, CultureInfo.InvariantCulture) == 0)
132 | {
133 | return item;
134 | }
135 | }
136 | return null;
137 | }
138 | }
139 |
140 | public CookieItem this[int index]
141 | {
142 | get
143 | {
144 | return (CookieItem) base.List[index];
145 | }
146 | }
147 | }
148 | }
149 |
150 |
--------------------------------------------------------------------------------
/Libraries/NetLib/SubmitFileRequestItem.cs:
--------------------------------------------------------------------------------
1 | namespace osu_common.Libraries.NetLib
2 | {
3 | using System;
4 | using System.Collections;
5 | using System.ComponentModel;
6 | using System.IO;
7 |
8 | public class SubmitFileRequestItem : HttpRequestItem
9 | {
10 | private string contentType;
11 | private const string DefaultContentType = "application/octet-stream";
12 | private const string DefaultFieldName = "FileName";
13 | private string fieldName;
14 | private string fileName;
15 | private byte[] bytes;
16 |
17 | public SubmitFileRequestItem()
18 | {
19 | this.fieldName = "FileName";
20 | this.fileName = string.Empty;
21 | this.contentType = "application/octet-stream";
22 | }
23 |
24 | public SubmitFileRequestItem(string fileName, string fieldName)
25 | {
26 | this.fieldName = fieldName;
27 | this.fileName = fileName;
28 | this.contentType = "application/octet-stream";
29 | }
30 |
31 | public SubmitFileRequestItem(string fileName, string fieldName, string contentType)
32 | {
33 | this.fieldName = fieldName;
34 | this.fileName = fileName;
35 | this.contentType = contentType;
36 | }
37 |
38 | public void AddDataArray(byte[] data)
39 | {
40 | bytes = data;
41 | }
42 |
43 | protected internal override void AddData(byte[] data, int index, int length)
44 | {
45 | if (base.Owner != null)
46 | {
47 | if (base.Owner.dataStream == null)
48 | {
49 | GetDataStreamEventArgs e = new GetDataStreamEventArgs(this);
50 | base.Owner.OnGetDataStream(e);
51 | base.Owner.dataStream = e.Stream;
52 | }
53 | if (base.Owner.dataStream != null)
54 | {
55 | base.Owner.dataStream.Write(data, index, length);
56 | }
57 | }
58 | }
59 |
60 | protected internal override void AfterAddData()
61 | {
62 | if ((base.Owner != null) && (base.Owner.dataStream != null))
63 | {
64 | base.Owner.dataStream.Seek(0L, SeekOrigin.Begin);
65 | base.Owner.OnDataAdded(new DataAddedEventArgs(this, base.Owner.dataStream));
66 | }
67 | }
68 |
69 | public override Stream GetData()
70 | {
71 | Stream stream2;
72 | if ((base.Owner == null) || !base.Owner.IsMultiPart())
73 | {
74 | return Stream.Null;
75 | }
76 | MultiStream stream = new MultiStream();
77 | try
78 | {
79 | stream.AddStream(new StringStream("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n", new object[] { base.GetCanonicalizedValue(this.FieldName), base.GetCanonicalizedValue(Utils.ExtractFileName(this.FileName)), this.ContentType }));
80 | GetDataStreamEventArgs e = new GetDataStreamEventArgs(this);
81 | base.Owner.OnGetDataSourceStream(e);
82 | if (e.Stream == null)
83 | {
84 | if (bytes == null)
85 | stream.AddStream(new FileStream(this.FileName, FileMode.Open, FileAccess.Read, FileShare.Read));
86 | else
87 | stream.AddStream(new MemoryStream(bytes));
88 | }
89 | else
90 | {
91 | stream.AddStream(e.Stream);
92 | }
93 | stream2 = stream;
94 | }
95 | catch (Exception exception)
96 | {
97 | stream.Close();
98 | throw exception;
99 | }
100 | return stream2;
101 | }
102 |
103 | protected internal override void ParseHeader(IList header, HeaderFieldList fieldList)
104 | {
105 | base.ParseHeader(header, fieldList);
106 | this.ContentType = HeaderFieldList.GetHeaderFieldValue(header, fieldList, "Content-Type");
107 | string source = HeaderFieldList.GetHeaderFieldValue(header, fieldList, "Content-Disposition");
108 | this.FieldName = HeaderFieldList.GetHeaderFieldValueItem(source, "name=");
109 | }
110 |
111 | [DefaultValue("application/octet-stream")]
112 | public string ContentType
113 | {
114 | get
115 | {
116 | return this.contentType;
117 | }
118 | set
119 | {
120 | if (this.contentType != value)
121 | {
122 | this.contentType = value;
123 | base.Update();
124 | }
125 | }
126 | }
127 |
128 | [DefaultValue("FileName")]
129 | public string FieldName
130 | {
131 | get
132 | {
133 | return this.fieldName;
134 | }
135 | set
136 | {
137 | if (this.fieldName != value)
138 | {
139 | this.fieldName = value;
140 | base.Update();
141 | }
142 | }
143 | }
144 |
145 | [DefaultValue("")]
146 | public string FileName
147 | {
148 | get
149 | {
150 | return this.fileName;
151 | }
152 | set
153 | {
154 | if (this.fileName != value)
155 | {
156 | this.fileName = value;
157 | base.Update();
158 | }
159 | }
160 | }
161 | }
162 | }
163 |
164 |
--------------------------------------------------------------------------------
/DockedPanel.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/QuickStart.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------