<property name="can_focus">False</property>
<property name="model">PresenceListStore</property>
<property name="id_column">0</property>
- <property name="active_id">available</property>
+ <property name="active_id">unavailable</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
XMPPConnection *connection;
XMPPRoster *roster;
XMPPStreamManagement *streamManagement;
+ XMPPPresence *presence;
id<JubUI> ui;
}
@property (readonly) XMPPConnection *connection;
@property (readonly) XMPPRoster *roster;
+@property (readonly) XMPPPresence *presence;
@property (assign) id<JubUI> ui;
- initWithConfig: (JubConfig*)config;
@implementation JubChatClient
@synthesize connection;
@synthesize roster;
+@synthesize presence;
@synthesize ui;
- initWithConfig: (JubConfig*)config
[roster release];
[streamManagement release];
[connection release];
+ [presence release];
[super dealloc];
}
-- (void)connection: (XMPPConnection*)conn_
+- (void)connection: (XMPPConnection*)connection_
wasBoundToJID: (XMPPJID*)jid
{
of_log(@"Bound to JID: %@", [jid fullJID]);
[roster requestRoster];
}
+- (void)connection: (XMPPConnection*)connection_
+ didReceivePresence: (XMPPPresence*)presence_
+{
+ if ([presence_.from isEqual: connection.JID]) {
+ [ui client: self
+ didChangePresence: presence_];
+ OF_SETTER(presence, presence_, YES, 0);
+ }
+}
+
- (void)rosterWasReceived: (XMPPRoster*)roster
{
- [connection sendStanza: [XMPPPresence presence]];
+ XMPPPresence *pres = [XMPPPresence presence];
+ [pres addStatus: @"Hello from JubJub"];
+ [connection sendStanza: pres];
}
@end
-#import <ObjXMPP/XMPPRoster.h>
-
@class JubChatClient;
+@class XMPPPresence;
@protocol JubUI
- initWithClient: (JubChatClient*)client;
- (void)startUIThread;
+- (void)client: (JubChatClient*)client
+ didChangePresence: (XMPPPresence*)presence;
@end
GtkWidget *roster_window;
GtkTreeStore *roster_model;
GtkTreeModelFilter *roster_filter;
+ GtkComboBox *presence_combo;
OFMapTable *groupMap;
OFMutableDictionary *contactMap;
OFMutableDictionary *chatMap;
- initWithClient: (JubChatClient*)client;
- (JubGtkChatUI*)chatForJID: (XMPPJID*)jid;
+- (void)client: (JubChatClient*)client
+ didChangePresence: (XMPPPresence*)presence;
@end
+#import <ObjXMPP/namespaces.h>
+#include <string.h>
+
#import "JubGtkRosterUI.h"
#import "JubGObjectMap.h"
#import "JubGtkChatUI.h"
#import "JubGtkHelper.h"
-#include <string.h>
-
static void roster_row_activated(GtkTreeView *tree_view, GtkTreePath *path,
GtkTreeViewColumn *column, gpointer data)
{
@try {
GtkTreeView *roster_view;
- GtkComboBox *presence_combo;
GtkBuilder *builder;
groupMap = [[OFMapTable alloc]
}
}
+- (void)client: (JubChatClient*)client
+ didChangePresence: (XMPPPresence*)presence
+{
+ OFString *tooltip = @"";
+ OFString *show =
+ [[presence elementForName: @"show"
+ namespace: XMPP_NS_CLIENT] stringValue];
+ OFString *status =
+ [[presence elementForName: @"status"
+ namespace: XMPP_NS_CLIENT] stringValue];
+
+ if (status != nil)
+ tooltip = [@"<b>Status:</b> " stringByAppendingString: status];
+
+ // FIXME: Changing the active id will send another presence
+ g_idle_add_block(^{
+ if ([presence.type isEqual: @"unavailable"])
+ gtk_combo_box_set_active_id(presence_combo,
+ "unavailable");
+ else if (show == nil)
+ gtk_combo_box_set_active_id(presence_combo,
+ "available");
+ else
+ gtk_combo_box_set_active_id(presence_combo,
+ [show UTF8String]);
+
+
+ gtk_widget_set_tooltip_markup(GTK_WIDGET(presence_combo),
+ [tooltip UTF8String]);
+ });
+}
@end
return nil;
}] start];
}
+
+- (void)client: (JubChatClient*)client
+ didChangePresence: (XMPPPresence*)presence
+{
+ [rosterUI client: client
+ didChangePresence: presence];
+}
@end