summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-08-01 23:17:07 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-08-01 23:17:07 (GMT)
commit188ff36e3fbfdc174ea75babc1deb3aebcf1472b (patch)
treeb8d4f9153acec5b399ece8486c8c9276d8395858
parentaa3b4c09352cdfb2f999fc6c12faed6339405d03 (diff)
downloadswift-contrib-188ff36e3fbfdc174ea75babc1deb3aebcf1472b.zip
swift-contrib-188ff36e3fbfdc174ea75babc1deb3aebcf1472b.tar.bz2
Report XMPP server errors in Slimber.
-rw-r--r--Slimber/Cocoa/Menulet.h5
-rw-r--r--Slimber/Cocoa/Menulet.m13
-rw-r--r--Slimber/Cocoa/Slimber.h4
-rw-r--r--Slimber/Cocoa/Slimber.mm21
4 files changed, 34 insertions, 9 deletions
diff --git a/Slimber/Cocoa/Menulet.h b/Slimber/Cocoa/Menulet.h
index fabaa80..823213f 100644
--- a/Slimber/Cocoa/Menulet.h
+++ b/Slimber/Cocoa/Menulet.h
@@ -5,12 +5,13 @@
NSMenu* statusMenu;
NSImage* menuIcon;
NSArray* userNames;
- BOOL selfOnline;
+ BOOL xmppOnline;
+ NSString* xmppStatus;
}
- (id) init;
- (void) updateMenu;
- (void) setUserNames: (NSArray*) names;
-- (void) setSelfConnected: (BOOL) online;
+- (void) setXMPPStatus: (NSString*) status online: (BOOL) online;
@end
diff --git a/Slimber/Cocoa/Menulet.m b/Slimber/Cocoa/Menulet.m
index 1cc1f1f..2a62992 100644
--- a/Slimber/Cocoa/Menulet.m
+++ b/Slimber/Cocoa/Menulet.m
@@ -12,8 +12,9 @@
[statusItem setToolTip: @"Slimber"];
[statusItem setMenu: statusMenu];
+ xmppStatus = @"";
+ xmppOnline = NO;
userNames = [[NSArray alloc] init];
- selfOnline = NO;
[self updateMenu];
}
@@ -65,12 +66,11 @@
NSMenuItem* loggedInItem;
NSBundle* bundle = [NSBundle bundleForClass: [self class]];
NSString* path;
- if (selfOnline) {
- loggedInItem = [[NSMenuItem alloc] initWithTitle: @"You are logged in" action: NULL keyEquivalent: @""];
+ loggedInItem = [[NSMenuItem alloc] initWithTitle: xmppStatus action: NULL keyEquivalent: @""];
+ if (xmppOnline) {
path = [bundle pathForResource: @"Online" ofType:@"png"];
}
else {
- loggedInItem = [[NSMenuItem alloc] initWithTitle: @"You are not logged in" action: NULL keyEquivalent: @""];
path = [bundle pathForResource: @"Offline" ofType:@"png"];
}
[loggedInItem setImage: [[NSImage alloc] initWithContentsOfFile: path]];
@@ -89,8 +89,9 @@
[statusMenu addItem: exitMenuItem];
}
-- (void) setSelfConnected: (BOOL) online {
- selfOnline = online;
+- (void) setXMPPStatus: (NSString*) status online: (BOOL) online {
+ xmppStatus = status; // TODO: Should I retain status?
+ xmppOnline = online;
[self updateMenu];
}
diff --git a/Slimber/Cocoa/Slimber.h b/Slimber/Cocoa/Slimber.h
index b62f9e5..fdce501 100644
--- a/Slimber/Cocoa/Slimber.h
+++ b/Slimber/Cocoa/Slimber.h
@@ -1,6 +1,9 @@
#pragma once
#include <boost/shared_ptr.hpp>
+#include <boost/optional.hpp>
+
+#include "Slimber/ServerError.h"
@class Menulet;
namespace Swift {
@@ -18,6 +21,7 @@ class Slimber {
private:
void handleSelfConnected(bool b);
void handleServicesChanged();
+ void handleServerStopped(boost::optional<Swift::ServerError> error);
private:
boost::shared_ptr<Swift::BonjourQuerier> dnsSDQuerier;
diff --git a/Slimber/Cocoa/Slimber.mm b/Slimber/Cocoa/Slimber.mm
index d4851c8..9e15614 100644
--- a/Slimber/Cocoa/Slimber.mm
+++ b/Slimber/Cocoa/Slimber.mm
@@ -30,11 +30,16 @@ Slimber::Slimber() {
PlatformApplication("Slimber").getSettingsDir());
server = new Server(5222, 5562, linkLocalServiceBrowser, vCardCollection);
+ server->onStopped.connect(
+ boost::bind(&Slimber::handleServerStopped, this, _1));
server->onSelfConnected.connect(
boost::bind(&Slimber::handleSelfConnected, this, _1));
menulet = [[Menulet alloc] init];
+ handleSelfConnected(false);
handleServicesChanged();
+
+ server->start();
}
Slimber::~Slimber() {
@@ -47,7 +52,12 @@ Slimber::~Slimber() {
}
void Slimber::handleSelfConnected(bool b) {
- [menulet setSelfConnected: b];
+ if (b) {
+ [menulet setXMPPStatus: @"You are logged in" online: true];
+ }
+ else {
+ [menulet setXMPPStatus: @"You are not logged in" online: false];
+ }
}
void Slimber::handleServicesChanged() {
@@ -59,3 +69,12 @@ void Slimber::handleServicesChanged() {
[menulet setUserNames: names];
[names release];
}
+
+void Slimber::handleServerStopped(boost::optional<ServerError> error) {
+ if (error) {
+ [menulet setXMPPStatus: @"XMPP Server Error." online: false];
+ }
+ else {
+ [menulet setXMPPStatus: @"XMPP Server Not Runnning." online: false];
+ }
+}