|
20
by Ken VanDine
added header to mono-example.cs |
1 |
/*
|
2 |
* Copyright (C) 2010 Canonical Ltd.
|
|
3 |
*
|
|
4 |
* This library is free software; you can redistribute it and/or modify
|
|
5 |
* it under the terms of the GNU Lesser General Public License
|
|
6 |
* version 3.0 as published by the Free Software Foundation.
|
|
7 |
*
|
|
8 |
* This library is distributed in the hope that it will be useful,
|
|
9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
* GNU Lesser General Public License version 3.0 for more details.
|
|
12 |
*
|
|
13 |
* You should have received a copy of the GNU Lesser General Public
|
|
14 |
* License along with this library. If not, see
|
|
15 |
* <http://www.gnu.org/licenses/>.
|
|
16 |
*
|
|
17 |
* Authored by Ken VanDine <ken.vandine@canonical.com>
|
|
18 |
*/
|
|
19 |
||
|
14
by Ken VanDine
fixed the mono example to not crash |
20 |
using System; |
21 |
using Gwibber; |
|
22 |
using GLib; |
|
23 |
||
24 |
namespace GwibberExample |
|
25 |
{
|
|
26 |
class MainClass |
|
27 |
{
|
|
|
15
by Ken VanDine
moved mono examples into a single file |
28 |
public static void Main (string[] args) { |
|
14
by Ken VanDine
fixed the mono example to not crash |
29 |
GType.Init (); |
|
15
by Ken VanDine
moved mono examples into a single file |
30 |
|
31 |
for (int idx = 0; idx < args.Length; idx++) { |
|
32 |
switch (args [idx]) { |
|
33 |
case "--refresh": |
|
34 |
Refresh (); |
|
35 |
break; |
|
|
43
by Ken VanDine
* Added missing example file |
36 |
case "--version": |
37 |
Console.WriteLine ("Gwibber service version: " + Version ()); |
|
|
15
by Ken VanDine
moved mono examples into a single file |
38 |
break; |
|
75
by Ken VanDine
* Added Gwibber.Service.start method for starting gwibber-service |
39 |
case "--start": |
40 |
Start (); |
|
41 |
break; |
|
42 |
case "--shutdown": |
|
43 |
Quit (); |
|
44 |
break; |
|
|
63
by Ken VanDine
* Renamed the example source files to be more reflective of what the example is |
45 |
case "--accounts": |
46 |
List (); |
|
47 |
break; |
|
|
15
by Ken VanDine
moved mono examples into a single file |
48 |
case "--send-message": |
49 |
if (idx + 1 < args.Length |
|
50 |
&& args [idx + 1] != null |
|
51 |
&& args [idx + 1] != String.Empty |
|
52 |
&& args [idx + 1][0] != '-') { |
|
53 |
SendMessage ((string) args [++idx]); |
|
54 |
} else { |
|
55 |
PrintUsage(); |
|
56 |
}
|
|
57 |
break; |
|
58 |
case "--help": |
|
59 |
case "--usage": |
|
60 |
PrintUsage (); |
|
61 |
break; |
|
62 |
default: |
|
|
43
by Ken VanDine
* Added missing example file |
63 |
PrintUsage (); |
|
15
by Ken VanDine
moved mono examples into a single file |
64 |
break; |
65 |
}
|
|
66 |
}
|
|
67 |
}
|
|
68 |
||
69 |
public static void PrintUsage () { |
|
70 |
string usage = "Usage:\n" + |
|
71 |
" --help\t\t\tPrint this usage message.\n" + |
|
|
75
by Ken VanDine
* Added Gwibber.Service.start method for starting gwibber-service |
72 |
" --start\t\t\tStart the gwibber-service\n" + |
73 |
" --shutdown\t\t\tShutdown the gwibber-service\n" + |
|
|
15
by Ken VanDine
moved mono examples into a single file |
74 |
" --refresh\t\t\tRefresh the gwibber-service\n" + |
|
63
by Ken VanDine
* Renamed the example source files to be more reflective of what the example is |
75 |
" --accounts\t\t\tList accounts\n" + |
|
15
by Ken VanDine
moved mono examples into a single file |
76 |
" --send-message [message]\t\tMessage to post\n" + |
|
43
by Ken VanDine
* Added missing example file |
77 |
" --version\t\t\tReturns the version of the gwibber-service\n"; |
|
15
by Ken VanDine
moved mono examples into a single file |
78 |
Console.WriteLine (usage); |
79 |
}
|
|
80 |
||
|
75
by Ken VanDine
* Added Gwibber.Service.start method for starting gwibber-service |
81 |
public static void Start () { |
82 |
Gwibber.Service service = new Gwibber.Service (); |
|
83 |
service.Start (); |
|
84 |
Console.WriteLine ("Starting the Gwibber service"); |
|
85 |
}
|
|
86 |
||
87 |
public static void Quit () { |
|
88 |
Gwibber.Service service = new Gwibber.Service (); |
|
89 |
service.Quit (); |
|
90 |
Console.WriteLine ("Shutting down the Gwibber service"); |
|
91 |
}
|
|
92 |
||
|
15
by Ken VanDine
moved mono examples into a single file |
93 |
public static void Refresh () { |
94 |
Gwibber.Service service = new Gwibber.Service (); |
|
95 |
service.Refresh (); |
|
|
43
by Ken VanDine
* Added missing example file |
96 |
Console.WriteLine ("Gwibber service refreshed"); |
|
15
by Ken VanDine
moved mono examples into a single file |
97 |
}
|
98 |
||
|
43
by Ken VanDine
* Added missing example file |
99 |
public static string Version () { |
|
15
by Ken VanDine
moved mono examples into a single file |
100 |
Gwibber.Service service = new Gwibber.Service (); |
101 |
string version = service.Version (); |
|
102 |
return version; |
|
103 |
}
|
|
104 |
||
105 |
public static void SendMessage (string message) { |
|
106 |
Gwibber.Service service = new Gwibber.Service (); |
|
107 |
service.SendMessage (message); |
|
|
14
by Ken VanDine
fixed the mono example to not crash |
108 |
}
|
|
63
by Ken VanDine
* Renamed the example source files to be more reflective of what the example is |
109 |
public static void List () { |
110 |
Gwibber.Accounts accounts_service = new Gwibber.Accounts (); |
|
111 |
var accounts = accounts_service.List (); |
|
112 |
}
|
|
|
14
by Ken VanDine
fixed the mono example to not crash |
113 |
}
|
114 |
}
|
|
|
15
by Ken VanDine
moved mono examples into a single file |
115 |
|
116 |