/
EvernoteConnect.cs
64 lines (53 loc) · 1.93 KB
/
EvernoteConnect.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
using System;
using Evernote.EDAM.NoteStore;
using Evernote.EDAM.UserStore;
using Thrift.Protocol;
using Thrift.Transport;
using VVVV.PluginInterfaces.V2;
namespace VVVV.Nodes.Evernote
{
[PluginInfo(Name = "Connect", Category = "Evernote", Help = "", Tags = "")]
public class EvernoteConnect : IPluginEvaluate
{
[Input("Connect", IsBang = true, IsSingle = true)]
private ISpread<bool> FConnectIn;
[Input("Token", IsSingle = true)]
private ISpread<string> FTokenIn;
[Output("Evernote", IsSingle = true)]
private ISpread<Evernote> FEvernoteOut;
//Evernote Routine
private string FEvernoteHost = "sandbox.evernote.com";
private Uri FUserStoreUrl;
private TTransport FUserStoreTransport;
private TProtocol FUserStoreProtocol;
private UserStore.Client FUserStore;
private string FNoteStoreUrl;
private TTransport FNoteStoreTransport;
private TProtocol FNoteStoreProtocol;
private NoteStore.Client FNoteStore;
public EvernoteConnect()
{
FUserStoreUrl = new Uri("https://" + FEvernoteHost + "/edam/user");
FUserStoreTransport = new THttpClient(FUserStoreUrl);
FUserStoreProtocol = new TBinaryProtocol(FUserStoreTransport);
FUserStore = new UserStore.Client(FUserStoreProtocol);
}
private void Init()
{
FNoteStoreUrl = FUserStore.getNoteStoreUrl(FTokenIn[0]);
FNoteStoreTransport = new THttpClient(new Uri(FNoteStoreUrl));
FNoteStoreProtocol = new TBinaryProtocol(FNoteStoreTransport);
FNoteStore = new NoteStore.Client(FNoteStoreProtocol);
}
public void Evaluate(int spreadMax)
{
FEvernoteOut[0] = new Evernote(){Token = FTokenIn[0], UserStore = FUserStore, NoteStore = FNoteStore};
}
}
public struct Evernote
{
public string Token;
public UserStore.Client UserStore;
public NoteStore.Client NoteStore;
}
}