Skip to content
Browse files

Merge branch 'master' into proxy

  • Loading branch information...
2 parents f31435e + 672aa2d commit 14856eb5e98c4293604a8f69f0d839b6625ae8d6 @codebutler committed Mar 24, 2009
View
5 Synapse.mds
@@ -1,5 +1,4 @@
-<Combine name="Synapse" fileversion="2.0">
- <Policies />
+<Combine fileversion="2.0" name="Synapse">
<Configurations active="Debug">
<Configuration name="Debug" ctype="CombineConfiguration">
<Entry build="True" name="Synapse.Core" configuration="Debug" />
@@ -20,7 +19,7 @@
<Entry build="True" name="Unit Tests" configuration="Release" />
</Configuration>
</Configurations>
- <StartMode startupentry="Synapse.Core" single="True">
+ <StartMode startupentry="Synapse.QtClient" single="True">
<Execute type="None" entry="Synapse.Core" />
<Execute type="None" entry="Synapse.Services" />
<Execute type="None" entry="Synapse.Xmpp" />
View
12 src/Synapse.QtClient/GlobalActions.cs
@@ -36,24 +36,24 @@ public GlobalActions()
{
m_AccountsMenu = new QMenu();
- m_QuitAction = new QAction(Gui.LoadIcon("gtk-quit"), "Quit", this);
+ m_QuitAction = new QAction(Gui.LoadIcon("application-exit"), "Quit", this);
m_QuitAction.Shortcut = new QKeySequence("Ctrl+Q");
QObject.Connect(m_QuitAction, Qt.SIGNAL("triggered()"), HandleQuitActionTriggered);
- m_ShowPreferencesAction = new QAction(Gui.LoadIcon("gtk-preferences"), "Preferences", this);
+ m_ShowPreferencesAction = new QAction(Gui.LoadIcon("preferences-desktop"), "Preferences", this);
QObject.Connect(m_ShowPreferencesAction, Qt.SIGNAL("triggered()"), HandleShowPreferencesActionTriggered);
m_SendFeedbackAction = new QAction("Send Feedback...", this);
QObject.Connect(m_SendFeedbackAction, Qt.SIGNAL("triggered()"), HandleSendFeedbackActionTriggered);
- m_ShowBrowserAction = new QAction(Gui.LoadIcon("search"), "Discover Services...", this);
+ m_ShowBrowserAction = new QAction(Gui.LoadIcon("system-search"), "Discover Services...", this);
QObject.Connect(m_ShowBrowserAction, Qt.SIGNAL("triggered()"), HandleShowBrowserActionTriggered);
- m_NewMessageAction = new QAction(Gui.LoadIcon("gtk-new"), "New Message...", this);
+ m_NewMessageAction = new QAction(Gui.LoadIcon("document-new"), "New Message...", this);
m_JoinMucAction = new QAction(Gui.LoadIcon("internet-group-chat"), "Create/Join Conference...", this);
- m_EditProfileAction = new QAction(Gui.LoadIcon("stock_person"), "Edit Profile...", this);
+ m_EditProfileAction = new QAction(Gui.LoadIcon("user-info"), "Edit Profile...", this);
QObject.Connect(m_EditProfileAction, Qt.SIGNAL("triggered()"), HandleEditProfileActionTriggered);
m_AboutAction = new QAction(Gui.LoadIcon("help-about"), "About", this);
@@ -191,4 +191,4 @@ void HandleAboutActionTriggered ()
aboutDialog.Show();
}
}
-}
+}
View
35 src/Synapse.QtClient/Synapse.QtClient.Widgets/AccountStatusWidget.cs
@@ -120,7 +120,7 @@ void OnAccountStateChanged (Account account)
string text = null;
string statusText = null;
if (account.Status != null) {
- text = account.Status.TypeDisplayName;
+ text = account.Status.AvailabilityDisplayName;
if (!String.IsNullOrEmpty(account.Status.StatusText)) {
statusText = account.Status.StatusText;
}
@@ -182,35 +182,42 @@ void on_m_StatusLabel_linkActivated(string link)
void HandlePresenceMenuTriggered(QAction action)
{
- m_Account.Status = new ClientStatus(action.Text, String.Empty);
+ if (action.Text != "Offline")
+ m_Account.Status = new ClientStatus(action.Text, String.Empty);
+ else
+ m_Account.Status = null;
}
void HandlePresenceMenuAboutToShow()
{
- if (m_Account.Status != null) {
- var currentStatus = m_Account.Status.Type;
- switch (currentStatus) {
- case ClientStatusType.Available:
+ if (m_Account.ConnectionState == AccountConnectionState.Connected) {
+ var currentAvailability = m_Account.Status.Availability;
+ switch (currentAvailability) {
+ case ClientAvailability.Available:
m_AvailableAction.Checked = true;
break;
- case ClientStatusType.FreeToChat:
+ case ClientAvailability.FreeToChat:
m_FreeToChatAction.Checked = true;
break;
- case ClientStatusType.Away:
+ case ClientAvailability.Away:
m_AwayAction.Checkable = true;
break;
- case ClientStatusType.ExtendedAway:
+ case ClientAvailability.ExtendedAway:
m_ExtendedAwayAction.Checked = true;
break;
- case ClientStatusType.DoNotDisturb:
+ case ClientAvailability.DoNotDisturb:
m_DoNotDisturbAction.Checked = true;
break;
- case ClientStatusType.Offline:
- m_OfflineAction.Checked = true;
- break;
}
- } else {
+ } else if (m_Account.ConnectionState == AccountConnectionState.Disconnected) {
m_OfflineAction.Checked = true;
+ } else {
+ m_AvailableAction.Checked = false;
+ m_FreeToChatAction.Checked = false;
+ m_AwayAction.Checkable = false;
+ m_ExtendedAwayAction.Checked = false;
+ m_DoNotDisturbAction.Checked = false;
+ m_OfflineAction.Checked = false;
}
}
}
View
4 src/Synapse.QtClient/Synapse.QtClient.Widgets/EditGroupsWidget.cs
@@ -35,7 +35,7 @@ public EditGroupsWidget (QWidget parent) : base (parent)
{
SetupUi();
- addButton.icon = Gui.LoadIcon("add", 16);
+ addButton.icon = Gui.LoadIcon("list-add", 16);
}
public Account Account {
@@ -104,4 +104,4 @@ void on_addButton_clicked ()
item.SetCheckState(Qt.CheckState.Checked);
}
}
-}
+}
View
4 src/Synapse.QtClient/Synapse.QtClient.Windows/AddFriendWindow.cs
@@ -41,7 +41,7 @@ public AddFriendWindow (Account account)
closeButton.icon = Gui.LoadIcon("window-close", 16);
- QPushButton addButton = new QPushButton(Gui.LoadIcon("add", 16), "Add Friend");
+ QPushButton addButton = new QPushButton(Gui.LoadIcon("list-add", 16), "Add Friend");
addButton.SetParent(buttonBox);
buttonBox.AddButton(addButton, QDialogButtonBox.ButtonRole.AcceptRole);
@@ -99,4 +99,4 @@ void AddRosterItemComplete (object sender, IQ response, object data)
}
}
}
-}
+}
View
6 src/Synapse.QtClient/Synapse.QtClient.Windows/ChatWindow.cs
@@ -223,7 +223,7 @@ internal ChatWindow (IChatHandler handler)
QObject.Connect<QAction>(formatMenu, Qt.SIGNAL("triggered(QAction*)"), HandleFormatMenuActionTriggered);
formatMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
formatMenuButton.Text = "Format";
- formatMenuButton.icon = Gui.LoadIcon("fonts", 16);
+ formatMenuButton.icon = Gui.LoadIcon("preferences-desktop-font", 16);
formatMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
formatMenuButton.SetMenu(formatMenu);
toolbar.AddWidget(formatMenuButton);
@@ -257,7 +257,7 @@ internal ChatWindow (IChatHandler handler)
var insertMenuButton = new QToolButton(this);
insertMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
insertMenuButton.Text = "Insert";
- insertMenuButton.icon = Gui.LoadIcon("image", 16);
+ insertMenuButton.icon = Gui.LoadIcon("image-x-generic", 16);
insertMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
insertMenuButton.SetMenu(insertMenu);
toolbar.AddWidget(insertMenuButton);
@@ -291,7 +291,7 @@ internal ChatWindow (IChatHandler handler)
activitiesMenu.AddSeparator();
activitiesMenu.AddAction(Gui.LoadIcon("applications-graphics", 16), "Launch Whiteboard...");
- activitiesMenu.AddAction(Gui.LoadIcon("desktop", 16), "Share Desktop...");
+ activitiesMenu.AddAction(Gui.LoadIcon("user-desktop", 16), "Share Desktop...");
var spacerWidget = new QWidget(toolbar);
spacerWidget.SetSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed);
View
4 src/Synapse.QtClient/Synapse.QtClient.Windows/ErrorDialog.cs
@@ -30,7 +30,7 @@ public ErrorDialog (string errorTitle, string errorMessage, string errorDetail,
{
SetupUi();
- iconLabel.Pixmap = Gui.LoadIcon("error").Pixmap(32);
+ iconLabel.Pixmap = Gui.LoadIcon("dialog-error").Pixmap(32);
titleLabel.Text = "<b>" + Qt.Escape(errorTitle) + "</b>";
messageLabel.Text = !String.IsNullOrEmpty(errorMessage) ? errorMessage : String.Empty;
@@ -46,4 +46,4 @@ public ErrorDialog (string errorTitle, string errorMessage, string errorDetail,
Gui.CenterWidgetOnScreen(this);
}
}
-}
+}
View
10 src/Synapse.QtClient/Synapse.QtClient.Windows/ServiceBrowserWindow.cs
@@ -55,10 +55,10 @@ public ServiceBrowserWindow (Account account)
this.WindowTitle = String.Format("XMPP Browser - {0}", account.Jid);
- m_BackAction = new QAction(Gui.LoadIcon("back", 16), "Back", this);
- m_ForwardAction = new QAction(Gui.LoadIcon("forward", 16), "Forward", this);
- m_ReloadAction = new QAction(Gui.LoadIcon("reload", 16), "Reload", this);
- m_StopAction = new QAction(Gui.LoadIcon("stop", 16), "Stop", this);
+ m_BackAction = new QAction(Gui.LoadIcon("go-previous", 16), "Back", this);
+ m_ForwardAction = new QAction(Gui.LoadIcon("go-next", 16), "Forward", this);
+ m_ReloadAction = new QAction(Gui.LoadIcon("view-refresh", 16), "Reload", this);
+ m_StopAction = new QAction(Gui.LoadIcon("process-stop", 16), "Stop", this);
m_HomeAction = new QAction(Gui.LoadIcon("go-home", 16), "Home", this);
m_GoAction = new QAction("Go", this);
@@ -199,4 +199,4 @@ void ReceivedItems (DiscoManager manager, DiscoNode node, object state)
});
}
}
-}
+}
View
6 src/Synapse.QtClient/Synapse.QtClient.Windows/TabbedChatsWindow.cs
@@ -56,7 +56,7 @@ public TabbedChatsWindow()
QToolButton newTabButton = new QToolButton(m_Tabs);
newTabButton.AutoRaise = true;
- newTabButton.SetDefaultAction(new QAction(Gui.LoadIcon("stock_new-tab", 16), "New Tab", newTabButton));
+ newTabButton.SetDefaultAction(new QAction(Gui.LoadIcon("tab-new", 16), "New Tab", newTabButton));
newTabButton.SetToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly);
QObject.Connect<QAction>(newTabButton, Qt.SIGNAL("triggered(QAction*)"), HandleNewTab);
m_Tabs.SetCornerWidget(newTabButton, Qt.Corner.BottomLeftCorner);
@@ -68,7 +68,7 @@ public TabbedChatsWindow()
QToolButton closeTabButton = new QToolButton(m_Tabs);
closeTabButton.SetToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly);
closeTabButton.AutoRaise = true;
- closeTabButton.SetDefaultAction(new QAction(Gui.LoadIcon("stock_close", 16), "Close Tab", closeTabButton));
+ closeTabButton.SetDefaultAction(new QAction(Gui.LoadIcon("window-close", 16), "Close Tab", closeTabButton));
QObject.Connect<QAction>(closeTabButton, Qt.SIGNAL("triggered(QAction*)"), HandleCloseTab);
rightButtonsLayout.AddWidget(closeTabButton);
@@ -80,7 +80,7 @@ public TabbedChatsWindow()
trashButton.AutoRaise = true;
trashButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
trashButton.SetMenu(menu);
- trashButton.SetDefaultAction(new QAction(Gui.LoadIcon("trashcan_empty", 16), "Recently Closed Tabs", trashButton));
+ trashButton.SetDefaultAction(new QAction(Gui.LoadIcon("user-trash", 16), "Recently Closed Tabs", trashButton));
rightButtonsLayout.AddWidget(trashButton);
// FIXME: This looks bad.
View
29 src/Synapse.Services/Synapse.Services/ActivityFeedService.cs
@@ -81,7 +81,8 @@ public void AddTemplate (string name, string category, string singularText, stri
var template = new ActivityFeedItemTemplate(name, category, singularText, pluralText, desktopNotify, showInMainWindow, iconUrl, actions);
- m_Templates.Add(name, template);
+ lock (m_Templates)
+ m_Templates.Add(name, template);
if (!String.IsNullOrEmpty(category) && !m_Categories.Contains(category)) {
m_Categories.Add(category);
@@ -99,8 +100,25 @@ public void PostItem (IActivityFeedItem item)
lock (m_Queue)
m_Queue.Enqueue(item);
} else {
- NewItem(item);
+ RaiseNewItem(item);
}
+ }
+
+ public string ServiceName {
+ get { return "ActivityFeedService"; }
+ }
+
+ void RaiseNewItem (IActivityFeedItem item)
+ {
+ lock (m_Templates) {
+ if (!m_Templates.ContainsKey(item.Type)) {
+ throw new Exception("Unknown template: " + item.Type);
+ }
+ }
+
+ var evnt = NewItem;
+ if (evnt != null)
+ evnt(item);
var template = m_Templates[item.Type];
if (template.DesktopNotify) {
@@ -115,10 +133,7 @@ public void PostItem (IActivityFeedItem item)
}
Application.Client.DesktopNotify(template, item, text.ToString());
}
- }
-
- public string ServiceName {
- get { return "ActivityFeedService"; }
+
}
void FireQueued ()
@@ -128,7 +143,7 @@ void FireQueued ()
}
lock (m_Queue) {
while (m_Queue.Count > 0)
- NewItem(m_Queue.Dequeue());
+ RaiseNewItem(m_Queue.Dequeue());
}
}
}
View
48 src/Synapse.Xmpp/Synapse.Xmpp/Account.cs
@@ -234,7 +234,7 @@ void HandleOnAuthenticate(object sender)
if (m_PendingStatus != null) {
Status = m_PendingStatus;
} else {
- Status = new ClientStatus(ClientStatusType.Available, null);
+ Status = new ClientStatus(ClientAvailability.Available, null);
}
m_ConnectedAt = DateTime.Now;
@@ -538,35 +538,39 @@ public T GetFeature<T>()
set {
m_PendingStatus = null;
- if (value.Type != ClientStatusType.Offline && this.ConnectionState != AccountConnectionState.Connected) {
+ if (value == null) {
+ Disconnect();
+ return;
+ }
+
+ if (this.ConnectionState != AccountConnectionState.Connected) {
m_PendingStatus = value;
- Connect();
+
+ if (this.ConnectionState == AccountConnectionState.Disconnected)
+ Connect();
+
return;
}
- switch (value.Type) {
- case ClientStatusType.Available:
+ switch (value.Availability) {
+ case ClientAvailability.Available:
this.Client.Presence(PresenceType.available, value.StatusText, null, 0);
break;
- case ClientStatusType.FreeToChat:
+ case ClientAvailability.FreeToChat:
this.Client.Presence(PresenceType.available, value.StatusText, "chat", 0);
break;
- case ClientStatusType.Away:
+ case ClientAvailability.Away:
this.Client.Presence(PresenceType.available, value.StatusText, "away", 0);
break;
- case ClientStatusType.ExtendedAway:
+ case ClientAvailability.ExtendedAway:
this.Client.Presence(PresenceType.available, value.StatusText, "xa", 0);
break;
- case ClientStatusType.DoNotDisturb:
+ case ClientAvailability.DoNotDisturb:
this.Client.Presence(PresenceType.available, value.StatusText, "dnd", 0);
break;
- case ClientStatusType.Offline:
- this.Disconnect();
- break;
}
- if (value.Type != ClientStatusType.Offline)
- m_Status = value;
+ m_Status = value;
if (StatusChanged != null)
StatusChanged(this);
@@ -596,12 +600,15 @@ public void Connect()
m_Client.Port = m_ConnectPort;
m_Client.Password = m_Password;
- ConnectionState = AccountConnectionState.Connecting;
-
// FIXME: Calling this in a separate thread so DNS doesn't block the UI.
// This should be fixed inside jabber-net.
ThreadPool.QueueUserWorkItem(delegate {
- m_Client.Connect();
+ // Check that connection state hasn't changed by the time this executes.
+ // Might need to lock on something to avoid race condition...
+ if (ConnectionState == AccountConnectionState.Disconnected) {
+ ConnectionState = AccountConnectionState.Connecting;
+ m_Client.Connect();
+ }
});
}
@@ -644,7 +651,14 @@ public void Send (Packet packet, MessageEventHandler handler)
public void Disconnect()
{
+ // FIXME: This is a jabber-net bug!
+ if (ConnectionState == AccountConnectionState.Connecting) {
+ Console.Error.WriteLine("Can't disconnect while still connecting!");
+ return;
+ }
+
m_Client.Close();
+ ConnectionState = AccountConnectionState.Disconnected;
}
internal SerializableDictionary<string, string> Properties {
View
7 src/Synapse.Xmpp/Synapse.Xmpp/AvatarManager.cs
@@ -140,9 +140,12 @@ public static string GetAvatarFileName (JID jid)
}
void HandleOnPresence(object sender, Presence pres)
- {
+ {
+ if (pres.Type != PresenceType.available)
+ return;
+
// Make sure this isn't related to a MUC at all.
- // Is there really no better way?
+ // Is there really no better way? This isn't so reliable.
foreach (XmlNode element in pres.ChildNodes) {
if (element.NamespaceURI.StartsWith("http://jabber.org/protocol/muc")) {
return;
View
37 src/Synapse.Xmpp/Synapse.Xmpp/ClientStatus.cs
@@ -24,66 +24,61 @@
namespace Synapse.Xmpp
{
- public enum ClientStatusType
+ public enum ClientAvailability
{
Available,
FreeToChat,
Away,
ExtendedAway,
- DoNotDisturb,
- Invisible,
- Offline
+ DoNotDisturb
}
public class ClientStatus
{
- public ClientStatus(string typeDescription, string statusText)
+ public ClientStatus(string availabilityDescription, string statusText)
{
- switch (typeDescription) {
+ switch (availabilityDescription) {
case "Available":
case null:
- Type = ClientStatusType.Available;
+ Availability = ClientAvailability.Available;
break;
case "Free To Chat":
case "chat":
- Type = ClientStatusType.FreeToChat;
+ Availability = ClientAvailability.FreeToChat;
break;
case "Away":
case "away":
- Type = ClientStatusType.Away;
+ Availability = ClientAvailability.Away;
break;
case "Extended Away":
case "xa":
- Type = ClientStatusType.ExtendedAway;
+ Availability = ClientAvailability.ExtendedAway;
break;
case "Do Not Disturb":
case "dnd":
- Type = ClientStatusType.DoNotDisturb;
- break;
- case "Offline":
- Type = ClientStatusType.Offline;
+ Availability = ClientAvailability.DoNotDisturb;
break;
default:
- throw new ArgumentException("Unknown status type: " + typeDescription);
+ throw new ArgumentException("Unknown availability: " + availabilityDescription);
}
StatusText = statusText;
}
- public ClientStatus(ClientStatusType type, string statusText)
+ public ClientStatus(ClientAvailability availability, string statusText)
{
- Type = type;
- StatusText = statusText;
+ Availability = availability;
+ StatusText = statusText;
}
- public ClientStatusType Type {
+ public ClientAvailability Availability {
get;
set;
}
- public string TypeDisplayName {
+ public string AvailabilityDisplayName {
get {
- return Regex.Replace(this.Type.ToString(), @"(\B[A-Z])", @" $1");
+ return Regex.Replace(this.Availability.ToString(), @"(\B[A-Z])", @" $1");
}
}

0 comments on commit 14856eb

Please sign in to comment.
Something went wrong with that request. Please try again.