Skip to content

Commit

Permalink
Initial Version
Browse files Browse the repository at this point in the history
  • Loading branch information
vrokolos committed Sep 30, 2011
0 parents commit eb68a7c
Show file tree
Hide file tree
Showing 112 changed files with 3,106 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

bin/
obj/
UpgradeLog.XML
Binary file added Champs/Akali.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Alistar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Amumu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Anivia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Annie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Ashe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Blitzcrank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Brand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Caitlyn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Cassiopeia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/ChoGath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Corki.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/DrMundo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Evelynn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Ezreal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Fiddlesticks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Galio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Gangplank.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Garen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Gragas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Heimerdinger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Irelia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Janna.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/JarvanIV.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Jax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Champs/Karma.png
Binary file added Champs/Karthus.png
Binary file added Champs/Kassadin.png
Binary file added Champs/Katarina.png
Binary file added Champs/Kayle.png
Binary file added Champs/Kennen.png
Binary file added Champs/KogMaw.png
Binary file added Champs/LeBlanc.png
Binary file added Champs/LeeSin.png
Binary file added Champs/Leona.png
Binary file added Champs/Lux.png
Binary file added Champs/Malphite.png
Binary file added Champs/Malzahar.png
Binary file added Champs/Maokai.png
Binary file added Champs/MasterYi.png
Binary file added Champs/MissFortune.png
Binary file added Champs/MonkeyKing.png
Binary file added Champs/Mordekaiser.png
Binary file added Champs/Morgana.png
Binary file added Champs/Nasus.png
Binary file added Champs/Nidalee.png
Binary file added Champs/Nocturne.png
Binary file added Champs/Nunu.png
Binary file added Champs/Olaf.png
Binary file added Champs/Orianna.png
Binary file added Champs/OutOfGame.png
Binary file added Champs/Pantheon.png
Binary file added Champs/Poppy.png
Binary file added Champs/Rammus.png
Binary file added Champs/Renekton.png
Binary file added Champs/Riven.png
Binary file added Champs/Rumble.png
Binary file added Champs/Ryze.png
Binary file added Champs/Shaco.png
Binary file added Champs/Shen.png
Binary file added Champs/Singed.png
Binary file added Champs/Sion.png
Binary file added Champs/Sivir.png
Binary file added Champs/Skarner.png
Binary file added Champs/Sona.png
Binary file added Champs/Soraka.png
Binary file added Champs/Swain.png
Binary file added Champs/Talon.png
Binary file added Champs/Taric.png
Binary file added Champs/Teemo.png
Binary file added Champs/Tristana.png
Binary file added Champs/Trundle.png
Binary file added Champs/Tryndamere.png
Binary file added Champs/TwistedFate.png
Binary file added Champs/Twitch.png
Binary file added Champs/Udyr.png
Binary file added Champs/Urgot.png
Binary file added Champs/Vayne.png
Binary file added Champs/Veigar.png
Binary file added Champs/Vladimir.png
Binary file added Champs/Warwick.png
Binary file added Champs/XinZhao.png
Binary file added Champs/Yorick.png
Binary file added Champs/Zilean.png
Binary file added Champs/inQueue.png
Binary file added Champs/random.png
219 changes: 219 additions & 0 deletions JabberManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using jabber.client;
using System.ComponentModel;
using System.Security;
using System.Security.Cryptography;

namespace LolChatWin
{
public class JabberManager
{
public Dictionary<string, User> users = new Dictionary<string, User>();
public BindingList<User> theUsers = new BindingList<User>();
JabberClient c = new JabberClient();
RosterManager k = new RosterManager();

public delegate void UserChangedHandler(User e);
public event UserChangedHandler UserChanged;
public delegate void MsgHandler(User From, string message, DateTime Date);
public event MsgHandler OnMessage;

public delegate void ConnectedHandler();
public event ConnectedHandler OnConnect;
public event ConnectedHandler OnDisconnect;

public void Disconnect()
{
c.Close(true);
}

static byte[] entropy = System.Text.Encoding.Unicode.GetBytes("Salt Is Not A Password");

public static string EncryptString(System.Security.SecureString input)
{
byte[] encryptedData = System.Security.Cryptography.ProtectedData.Protect(
System.Text.Encoding.Unicode.GetBytes(ToInsecureString(input)),
entropy,
System.Security.Cryptography.DataProtectionScope.CurrentUser);
return Convert.ToBase64String(encryptedData);
}

public static SecureString DecryptString(string encryptedData)
{
try
{
byte[] decryptedData = System.Security.Cryptography.ProtectedData.Unprotect(
Convert.FromBase64String(encryptedData),
entropy,
System.Security.Cryptography.DataProtectionScope.CurrentUser);
return ToSecureString(System.Text.Encoding.Unicode.GetString(decryptedData));
}
catch
{
return new SecureString();
}
}

public static SecureString ToSecureString(string input)
{
SecureString secure = new SecureString();
foreach (char c in input)
{
secure.AppendChar(c);
}
secure.MakeReadOnly();
return secure;
}

public static string ToInsecureString(SecureString input)
{
string returnValue = string.Empty;
IntPtr ptr = System.Runtime.InteropServices.Marshal.SecureStringToBSTR(input);
try
{
returnValue = System.Runtime.InteropServices.Marshal.PtrToStringBSTR(ptr);
}
finally
{
System.Runtime.InteropServices.Marshal.ZeroFreeBSTR(ptr);
}
return returnValue;
}

public void Initialize(string username, string password, int server, ISynchronizeInvoke si )
{
c.InvokeControl = si;
c.OnPresence += new PresenceHandler(c_OnPresence);
c.User = username;
c.Password = "AIR_" + password;
c.Port = 5223;
c.SSL = true;
c.OnInvalidCertificate += new System.Net.Security.RemoteCertificateValidationCallback(c_OnInvalidCertificate);
c.AutoRoster = true;
c.AutoLogin = true;
c.AutoPresence = true;

if (server == 0 )
{
c.NetworkHost = "chat.na.lol.riotgames.com";
}
else if (server == 1)
{
c.NetworkHost = "chat.eu.lol.riotgames.com";
}
else
{
c.NetworkHost = "chat.eun1.lol.riotgames.com";
}
c.Server = "pvp.net";
k.Stream = c;

users.Clear();
theUsers.Clear();
k.OnRosterItem += new RosterItemHandler(k_OnRosterItem);
k.OnRosterEnd += new bedrock.ObjectHandler(k_OnRosterEnd);
c.OnMessage += new MessageHandler(c_OnMessage);
c.OnDisconnect += new bedrock.ObjectHandler(c_OnDisconnect);
c.OnAuthError += new jabber.protocol.ProtocolHandler(c_OnAuthError);

c.Connect();
}

bool c_OnInvalidCertificate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
}

void c_OnAuthError(object sender, System.Xml.XmlElement rp)
{
if (OnDisconnect != null)
{
OnDisconnect();
}
}

void c_OnDisconnect(object sender)
{
if (OnDisconnect != null)
{
OnDisconnect();
}
}

void k_OnRosterEnd(object sender)
{
if (OnConnect != null)
{
OnConnect();
}
}

void c_OnMessage(object sender, jabber.protocol.client.Message msg)
{
if (OnMessage != null)
{
if (users.ContainsKey(msg.From.User))
{
OnMessage(users[msg.From.User], msg.Body, DateTime.Now);
}
}
}
void k_OnRosterItem(object sender, jabber.protocol.iq.Item ri)
{

if (users.ContainsKey(ri.JID.User))
{
User us = users[ri.JID.User];
us.Nickname = ri.Nickname;
us.Group = ri.GetGroups().First().GroupName;
us.item = ri;
}
else
{
User us = new User(ri.JID.User, ri.Nickname, ri.GetGroups().First().GroupName, "", ri);
users.Add(ri.JID.User, us);
}
}

public void SendMessage(string text, User u)
{
c.Message(u.JID, text);
}

void c_OnPresence(object sender, jabber.protocol.client.Presence pres)
{
if (users.ContainsKey(pres.From.User))
{
users[pres.From.User].status = pres.Status;
}
else
{
User us = new User(pres.From.User, "", "", pres.Status, null);
users.Add(pres.From.User, us);
theUsers.Add(us);
}
if (users[pres.From.User].State == "offline")
{
users[pres.From.User].isOnline = false;
if (theUsers.Contains(users[pres.From.User]))
theUsers.Remove(users[pres.From.User]);

}
else
{
users[pres.From.User].isOnline = true;
if (!theUsers.Contains(users[pres.From.User]))
theUsers.Add(users[pres.From.User]);
}
if (theUsers.Contains(users[pres.From.User]))
{
if (UserChanged != null)
UserChanged(users[pres.From.User]);
}
}

}
}
Binary file added LOL_Icon.ico
Binary file not shown.
Loading

0 comments on commit eb68a7c

Please sign in to comment.