-
Notifications
You must be signed in to change notification settings - Fork 0
/
FirstTimeAuthentication.cs
85 lines (67 loc) · 2.3 KB
/
FirstTimeAuthentication.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Threading;
using Gtk;
using Glade;
using FlickrNet;
public class FirstTimeAuthentication
{
[Glade.Widget]
Dialog dialog1;
// Message to User window
[Glade.Widget]
TextView textview1;
// Done authentication button
[Glade.Widget]
Button button1;
// More Info button
[Glade.Widget]
Button button2;
[Glade.Widget]
Gtk.Image image1;
[Glade.Widget]
Gtk.Image image2;
private Flickr flickrObj;
private string frob;
private string _apikey = "413051629a00e140b4f448fd22d715d2";
private string _secret = "9aa8b5eef280f665";
private FirstTimeAuthentication()
{
Glade.XML gxml = new Glade.XML (null, "organizer.glade", "dialog1", null);
gxml.Autoconnect (this);
textview1.Buffer.Text = "The application needs to be authorized"
+ " before it can read or modify your photos and data on Flickr."
+ " Please go to the opened web browser window, to provide DFO"
+ " with the required permissions. When you're finished, return to this window to"
+ " complete authorization by clicking on Done.";
button1.Clicked += new EventHandler(OnButtonPressDone);
button2.Clicked += new EventHandler(OnButtonPressMoreInfo);
// Set images.
Gdk.Pixbuf pixbuf1 = new Gdk.Pixbuf(DeskFlickrUI.THUMBNAIL_PATH);
image1.Pixbuf = pixbuf1;
Gdk.Pixbuf pixbuf2 = new Gdk.Pixbuf(DeskFlickrUI.FLICKR_ICON);
image2.Pixbuf = pixbuf2;
dialog1.SetIconFromFile(DeskFlickrUI.ICON_PATH);
dialog1.ShowAll();
ConnectToFlickr();
}
public static void FireUp() {
new FirstTimeAuthentication();
}
private void OnButtonPressDone(object sender, EventArgs e) {
Auth auth = this.flickrObj.AuthGetToken(frob);
string token = auth.Token;
PersistentInformation.GetInstance().Token = token;
dialog1.Destroy();
}
private void OnButtonPressMoreInfo(object sender, EventArgs e) {
string moreInfoUrl =
"http://www.flickr.com/services/auth/list.gne";
System.Diagnostics.Process.Start(moreInfoUrl);
}
private void ConnectToFlickr() {
this.flickrObj = new Flickr(this._apikey, this._secret);
frob = this.flickrObj.AuthGetFrob();
string url = this.flickrObj.AuthCalcUrl(frob, AuthLevel.Delete);
System.Diagnostics.Process.Start(url);
}
}