Commit 2367b8db authored by Alex's avatar Alex
Browse files

upgraded examples to MatriX 2

added VB samples
parent 3e2bf750
......@@ -55,7 +55,7 @@ namespace MiniClient
private void cmdSend_Click(object sender, EventArgs e)
{
var msg = new Message {Type = MessageType.chat, To = _jid, Body = rtfSend.Text};
var msg = new Message {Type = MessageType.Chat, To = _jid, Body = rtfSend.Text};
_xmppClient.Send(msg);
OutgoingMessage(msg);
......
......@@ -61,7 +61,7 @@ namespace MiniClient
private void MessageCallback(object sender, MessageEventArgs e)
{
if (e.Message.Type == MessageType.groupchat)
if (e.Message.Type == MessageType.GroupChat)
IncomingMessage(e.Message);
}
......@@ -80,7 +80,7 @@ namespace MiniClient
var lvi = FindListViewItem(e.Presence.From);
if (lvi != null)
{
if (e.Presence.Type == PresenceType.unavailable)
if (e.Presence.Type == PresenceType.Unavailable)
{
lvi.Remove();
}
......@@ -129,7 +129,7 @@ namespace MiniClient
private void IncomingMessage(Matrix.Xmpp.Client.Message msg)
{
if (msg.Type == MessageType.error)
if (msg.Type == MessageType.Error)
{
//Handle errors here
// we dont handle them in this example
......@@ -168,7 +168,7 @@ namespace MiniClient
{
var msg = new Matrix.Xmpp.Client.Message
{
Type = MessageType.groupchat,
Type = MessageType.GroupChat,
To = _roomJid,
Body = rtfSend.Text
};
......@@ -189,7 +189,7 @@ namespace MiniClient
{
var msg = new Matrix.Xmpp.Client.Message
{
Type = MessageType.groupchat,
Type = MessageType.GroupChat,
To = _roomJid,
Subject = txtSubject.Text
};
......
......@@ -106,7 +106,7 @@ namespace MiniClient
//xmppClient.Uri = new System.Uri("http://matrix.ag-software.de/http-bind/");
xmppClient.Status = "ready for chat";
xmppClient.Show = Matrix.Xmpp.Show.chat;
xmppClient.Show = Matrix.Xmpp.Show.Chat;
if (!String.IsNullOrEmpty(txtHost.Text))
{
......@@ -166,7 +166,7 @@ namespace MiniClient
{
DisplayEvent(string.Format( "OnRosterItem\t{0}\t{1}", e.RosterItem.Jid, e.RosterItem.Name ));
if (e.RosterItem.Subscription != Subscription.remove)
if (e.RosterItem.Subscription != Subscription.Remove)
{
// set a default group name
string groupname = "Contacts";
......@@ -207,19 +207,19 @@ namespace MiniClient
{
DisplayEvent(string.Format("OnPresence\t{0}", e.Presence.From));
if (e.Presence.Type == PresenceType.subscribe)
if (e.Presence.Type == PresenceType.Subscribe)
{
}
else if (e.Presence.Type == PresenceType.subscribed)
else if (e.Presence.Type == PresenceType.Subscribed)
{
}
else if (e.Presence.Type == PresenceType.unsubscribe)
else if (e.Presence.Type == PresenceType.Unsubscribe)
{
}
else if (e.Presence.Type == PresenceType.unsubscribed)
else if (e.Presence.Type == PresenceType.Unsubscribed)
{
}
......@@ -230,7 +230,7 @@ namespace MiniClient
{
item.ImageIndex = Util.GetRosterImageIndex(e.Presence);
string resource = e.Presence.From.Resource;
if (e.Presence.Type != PresenceType.unavailable)
if (e.Presence.Type != PresenceType.Unavailable)
{
if (!item.Resources.Contains(resource))
item.Resources.Add(resource);
......@@ -255,10 +255,10 @@ namespace MiniClient
// we ignore GroupChat Messages here
if (e.Message.Type == MessageType.groupchat)
if (e.Message.Type == MessageType.GroupChat)
return;
if (e.Message.Type == MessageType.error)
if (e.Message.Type == MessageType.Error)
{
//Handle errors here
// we dont handle them in this example
......@@ -536,31 +536,31 @@ namespace MiniClient
private void presenceOnlineToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (xmppClient.StreamActive)
xmppClient.SendPresence(Matrix.Xmpp.Show.NONE);
xmppClient.SendPresence(Matrix.Xmpp.Show.None);
}
private void presenceChatToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (xmppClient.StreamActive)
xmppClient.SendPresence(Matrix.Xmpp.Show.chat);
xmppClient.SendPresence(Matrix.Xmpp.Show.Chat);
}
private void presenceAwayToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (xmppClient.StreamActive)
xmppClient.SendPresence(Matrix.Xmpp.Show.away);
xmppClient.SendPresence(Matrix.Xmpp.Show.Away);
}
private void presenceExtendedAwayToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (xmppClient.StreamActive)
xmppClient.SendPresence(Matrix.Xmpp.Show.xa);
xmppClient.SendPresence(Matrix.Xmpp.Show.ExtendedAway);
}
private void presenceDoNotDisturbToolStripMenuItem_Click(object sender, System.EventArgs e)
{
if (xmppClient.StreamActive)
xmppClient.SendPresence(Matrix.Xmpp.Show.dnd);
xmppClient.SendPresence(Matrix.Xmpp.Show.DoNotDisturb);
}
#endregion
}
......
......@@ -118,7 +118,7 @@ namespace MiniClient
</pubsub>
</iq>
*/
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
var pubsub = e.Iq.Element<PubSub>();
if (pubsub != null)
......@@ -127,7 +127,7 @@ namespace MiniClient
MessageBox.Show(String.Format("node {0} was created!", pubsub.Create.Node));
}
}
else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
{
string node = "";
......@@ -177,7 +177,7 @@ namespace MiniClient
private void DeleteNodeResult(object sender, IqEventArgs e)
{
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
var pNode = e.State as DiscoNode;
if (pNode != null)
......@@ -186,7 +186,7 @@ namespace MiniClient
pNode.Remove();
}
}
else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
{
// handle error here.
}
......@@ -199,7 +199,7 @@ namespace MiniClient
private void CreateInstantNodeResult(object sender, IqEventArgs e)
{
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
var pubsub = e.Iq.Element<PubSub>();
......@@ -209,7 +209,7 @@ namespace MiniClient
MessageBox.Show(String.Format("node {0} was created!", pubsub.Create.Node));
}
}
else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
{
// handle error here.
}
......@@ -231,11 +231,11 @@ namespace MiniClient
private void SubscribeResult(object sender, IqEventArgs e)
{
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
MessageBox.Show(String.Format("You are now subscribed to the node: {0}", e.State as string));
}
else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
{
// handle error here.
}
......@@ -265,11 +265,11 @@ namespace MiniClient
private void PublishResult(object sender, IqEventArgs e)
{
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
}
else if (e.Iq.Type == Matrix.Xmpp.IqType.error)
else if (e.Iq.Type == Matrix.Xmpp.IqType.Error)
{
// handle error here.
}
......
......@@ -39,19 +39,19 @@ namespace MiniClient
private void GetVcard(Jid jid)
{
var viq = new VcardIq {To = jid, Type = Matrix.Xmpp.IqType.get};
var viq = new VcardIq {To = jid, Type = Matrix.Xmpp.IqType.Get};
xmppClient.IqFilter.SendIq(viq, VcardResponse);
}
private void GetMyVcard()
{
var viq = new VcardIq {Type = Matrix.Xmpp.IqType.get };
var viq = new VcardIq {Type = Matrix.Xmpp.IqType.Get };
xmppClient.IqFilter.SendIq(viq, VcardResponse);
}
private void VcardResponse(object sender, IqEventArgs e)
{
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
var vc = e.Iq.Query as Vcard;
txtName.Text = vc.Fullname;
......@@ -66,7 +66,7 @@ namespace MiniClient
private void SetMyVcard()
{
var viq = new VcardIq { Type = Matrix.Xmpp.IqType.set };
var viq = new VcardIq { Type = Matrix.Xmpp.IqType.Set };
if (!string.IsNullOrEmpty(txtName.Text))
viq.Vcard.Fullname = txtName.Text;
......@@ -82,7 +82,7 @@ namespace MiniClient
private void VcardUpdateResponse(object sender, IqEventArgs e)
{
if (e.Iq.Type == Matrix.Xmpp.IqType.result)
if (e.Iq.Type == Matrix.Xmpp.IqType.Result)
{
MessageBox.Show("The VCard was updated successful!!");
}
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
......@@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Matrix">
<HintPath>..\..\..\bin\net35\Matrix.dll</HintPath>
<HintPath>..\..\packages\MatriX.2.0.0.1-pre\lib\net35\Matrix.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
......@@ -150,6 +150,7 @@
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
......@@ -71,18 +71,18 @@ namespace MiniClient
public static int GetRosterImageIndex(Presence pres)
{
if (pres.Type == PresenceType.unavailable)
if (pres.Type == PresenceType.Unavailable)
return 0;
switch (pres.Show)
{
case Show.chat:
case Show.Chat:
return 1;
case Show.away:
case Show.Away:
return 2;
case Show.xa:
case Show.ExtendedAway:
return 2;
case Show.dnd:
case Show.DoNotDisturb:
return 3;
default:
return 1;
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MatriX" version="2.0.0.1-pre" targetFramework="net35" />
</packages>
\ No newline at end of file
......@@ -8,6 +8,7 @@ namespace Reconnect
{
Matrix.License.LicenseManager.SetLicense(@"ENTER YOUR KEY HERE");
// TODO set your credentials here
var xmppWrapper = new ReconnectXmppWrapper("ag-software.de", "test", "secret");
xmppWrapper.Connect(null);
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
......@@ -33,7 +33,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Matrix">
<HintPath>..\..\..\bin\net35\Matrix.dll</HintPath>
<HintPath>..\..\packages\MatriX.2.0.0.1-pre\lib\net45\Matrix.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......@@ -50,6 +50,9 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MatriX" version="2.0.0.1-pre" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -10,6 +10,7 @@ namespace SendMessage
{
var xmppClient = new XmppClient
{
// TODO, add your credentials here
XmppDomain = "jabber.org",
Username = "user1",
Password = "secret"
......@@ -20,7 +21,7 @@ namespace SendMessage
xmppClient.Send(new Message
{
To = "user2@jabber.org",
Type = MessageType.chat,
Type = MessageType.Chat,
Body = "Hello World"
});
......
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
......@@ -35,9 +35,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Matrix, Version=1.1.0.1, Culture=neutral, PublicKeyToken=41a432ad608f2ff0, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\bin\net35\Matrix.dll</HintPath>
<Reference Include="Matrix">
<HintPath>..\..\packages\MatriX.2.0.0.1-pre\lib\net35\Matrix.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
......@@ -56,6 +55,9 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MatriX" version="2.0.0.1-pre" targetFramework="net35" />
</packages>
\ No newline at end of file
......@@ -95,7 +95,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Matrix">
<HintPath>..\..\..\bin\net35\Matrix.dll</HintPath>
<HintPath>..\..\packages\MatriX.2.0.0.1-pre\lib\net40\Matrix.dll</HintPath>
</Reference>
<Reference Include="System">
<Name>System</Name>
......@@ -148,6 +148,7 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
......
......@@ -189,7 +189,7 @@ namespace Server
if (e.Stanza is MxAuth)
{
var auth = e.Stanza as MxAuth;
if (auth.SaslMechanism == SaslMechanism.PLAIN)
if (auth.SaslMechanism == SaslMechanism.Plain)
ProcessSaslPlainAuth(auth);
}
}
......@@ -216,7 +216,7 @@ namespace Server
else
{
// connection not found. Return the message to the sender and stamp it with error
msg.Type = MessageType.error;
msg.Type = MessageType.Error;
msg.To = Jid;
msg.From = to;
msg.Add(new Matrix.Xmpp.Client.Error(Matrix.Xmpp.Base.ErrorCondition.ServiceUnavailable));
......@@ -227,24 +227,24 @@ namespace Server
private void ProcessPresence(Presence pres)
{
if (pres.Type == PresenceType.subscribe)
if (pres.Type == PresenceType.Subscribe)
{
// RFC 3.1.2. Server Processing of Outbound Subscription Request
}
else if (pres.Type == PresenceType.subscribed)
else if (pres.Type == PresenceType.Subscribed)
{
// RFC 3.1.5. Server Processing of Outbound Subscription Approval
}
else if (pres.Type == PresenceType.unsubscribed)
else if (pres.Type == PresenceType.Unsubscribed)
{
// RFC 3.2.2. Server Processing of Outbound Subscription Cancellation
}
else if (pres.Type == PresenceType.unsubscribe)
else if (pres.Type == PresenceType.Unsubscribe)
{
// RFC 3.3.2. Server Processing of Outbound Unsubscribe
}
else if (pres.Type == PresenceType.available
|| pres.Type == PresenceType.unavailable)
else if (pres.Type == PresenceType.Available
|| pres.Type == PresenceType.Unavailable)
{
ProcessOutboundPresence(pres);
}
......@@ -255,7 +255,7 @@ namespace Server
if (pres.To == null || pres.To.Equals(XmppDomain, new FullJidComparer()))
{
// a presence to the server
if (pres.Type == PresenceType.available)
if (pres.Type == PresenceType.Available)
{
if (IsBinded && !InitialPresence)
{
......@@ -275,7 +275,7 @@ namespace Server
}
}
}
else if (pres.Type == PresenceType.unavailable)
else if (pres.Type == PresenceType.Unavailable)
{
}
......@@ -331,19 +331,26 @@ namespace Server
RouteIq(iq);
else
{
// TODO
// something we don't understand or do not support, reply with error
Send(
new Matrix.Xmpp.Client.Iq()
{
Type = IqType.Error,
Id = iq.Id,
Error = new Matrix.Xmpp.Client.Error(Matrix.Xmpp.Base.ErrorCondition.FeatureNotImplemented)
});
}
}
private void ProcessRosterIq(Iq iq)
{
if (iq.Type == IqType.get)
if (iq.Type == IqType.Get)
{
// Send the roster
// we send a dummy roster here, you should retrieve it from a
// database or some kind of directory (LDAP, AD etc...)
iq.SwitchDirection();
iq.Type = IqType.result;
iq.Type = IqType.Result;
for (int i = 1; i < 11;i++)
{
// don't add yourself to the contact list (aka roster)
......@@ -354,14 +361,14 @@ namespace Server
{
Jid = new Jid("user" + i + "@" + XmppDomain),
Name = "User " + i,
Subscription = Subscription.both
Subscription = Subscription.Both
};
ri.AddGroup("Group 1");
iq.Query.Add(ri);
}
Send(iq);
}
else if (iq.Type == IqType.set)
else if (iq.Type == IqType.Set)
{
// TODO, handle roster add, remove and update here.
}
......@@ -407,7 +414,7 @@ namespace Server
{
{
// user does not exist or wrong password
Send(new Failure(FailureCondition.not_authorized));
Send(new Failure(FailureCondition.NotAuthorized));
}
}
}
......@@ -424,7 +431,7 @@ namespace Server
var resIq = new BindIq
{
Id = iq.Id,
Type = IqType.result,
Type = IqType.Result,
Bind = { Jid = jid }
};
......@@ -449,8 +456,8 @@ namespace Server
<session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
</iq>
*/
if (iq.Type == IqType.set)
Send(new SessionIq { Id = iq.Id, Type = IqType.result });
if (iq.Type == IqType.Set)
Send(new SessionIq { Id = iq.Id, Type = IqType.Result });
}
private void RouteIq(Iq iq)
......@@ -469,7 +476,7 @@ namespace Server
else
{
// connection not found. Return the message to the sender and stamp it with error
iq.Type = IqType.error;
iq.Type = IqType.Error;
iq.To = Jid;
iq.From = to;
iq.Add(new Matrix.Xmpp.Client.Error(Matrix.Xmpp.Base.ErrorCondition.ServiceUnavailable));
......@@ -500,7 +507,7 @@ namespace Server
if (!IsAuthenticated)
{
var mechs = new Mechanisms();
mechs.AddMechanism(SaslMechanism.PLAIN);
mechs.AddMechanism(SaslMechanism.Plain);
feat.Mechanisms = mechs;
}
else if (!IsBinded && IsAuthenticated)
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MatriX" version="2.0.0.1-pre" targetFramework="net40" />
</packages>
\ No newline at end of file
......@@ -72,7 +72,7 @@ namespace Weather
xmppClient.Password = txtPassword.Text;
xmppClient.Status = "I'm chatty";
xmppClient.Show = Matrix.Xmpp.Show.chat;
xmppClient.Show = Matrix.Xmpp.Show.Chat;
// set settings
login.User = txtUsername.Text;
......@@ -133,7 +133,7 @@ namespace Weather
{
DisplayEvent("OnIq");