viewpoint 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/examples/ews_fusefs.rb +0 -1
- data/lib/viewpoint/exchwebserv.rb +5 -2
- data/lib/viewpoint/folder.rb +43 -9
- data/lib/viewpoint/item.rb +20 -0
- data/test/test_client.rb +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/examples/ews_fusefs.rb
CHANGED
@@ -35,12 +35,13 @@ class Viewpoint::ExchWebServ
|
|
35
35
|
include Viewpoint
|
36
36
|
include Singleton
|
37
37
|
|
38
|
-
attr_reader :ews, :user, :authenticated
|
38
|
+
attr_reader :ews, :user, :authenticated, :email
|
39
39
|
|
40
40
|
def initialize
|
41
41
|
@authenticated = false
|
42
42
|
@user = nil
|
43
43
|
@pass = nil
|
44
|
+
@email = nil
|
44
45
|
@ews_endpoint = nil
|
45
46
|
|
46
47
|
# Connection to Exchange web services.
|
@@ -212,7 +213,9 @@ class Viewpoint::ExchWebServ
|
|
212
213
|
# were entered until later. The ResolveNames operation is completely
|
213
214
|
# arbitrary and could be any EWS call.
|
214
215
|
# http://msdn.microsoft.com/en-us/library/bb409286.aspx
|
215
|
-
resolve_name(@user)
|
216
|
+
resp = resolve_name(@user + '@')
|
217
|
+
# Set email while we're at it
|
218
|
+
@email = resp.resolutionSet.resolution.first.mailbox.emailAddress
|
216
219
|
|
217
220
|
rescue SOAP::HTTPStreamError
|
218
221
|
puts "Bad Login! Try Again."
|
data/lib/viewpoint/folder.rb
CHANGED
@@ -43,26 +43,26 @@ class Viewpoint::Folder
|
|
43
43
|
pull = PullSubscriptionRequestType.new
|
44
44
|
|
45
45
|
# Set-up folder Id
|
46
|
-
|
47
|
-
|
48
|
-
f_ids = NonEmptyArrayOfBaseFolderIdsType.new()
|
49
|
-
f_ids.distinguishedFolderId = dist_fid
|
46
|
+
f_id_t = FolderIdType.new
|
47
|
+
f_id_t.xmlattr_Id = @folder_id
|
48
|
+
f_ids = NonEmptyArrayOfBaseFolderIdsType.new([f_id_t],nil)
|
50
49
|
pull.folderIds = f_ids
|
51
50
|
|
52
51
|
# Set-up event types
|
53
52
|
event_types = NonEmptyArrayOfNotificationEventTypesType.new
|
54
|
-
|
53
|
+
event_types.push(NotificationEventTypeType::CopiedEvent)
|
55
54
|
event_types.push(NotificationEventTypeType::CreatedEvent)
|
56
55
|
event_types.push(NotificationEventTypeType::DeletedEvent)
|
57
|
-
|
56
|
+
event_types.push(NotificationEventTypeType::ModifiedEvent)
|
58
57
|
event_types.push(NotificationEventTypeType::MovedEvent)
|
58
|
+
event_types.push(NotificationEventTypeType::NewMailEvent)
|
59
59
|
pull.eventTypes = event_types
|
60
60
|
|
61
61
|
pull.timeout = 10
|
62
62
|
|
63
63
|
subscribe.pullSubscriptionRequest = pull
|
64
64
|
|
65
|
-
resp = ExchWebServ.instance.ews.subscribe(subscribe).responseMessages.subscribeResponseMessage
|
65
|
+
resp = ExchWebServ.instance.ews.subscribe(subscribe).responseMessages.subscribeResponseMessage.first
|
66
66
|
@subscription_id = resp.subscriptionId
|
67
67
|
@watermark = resp.watermark
|
68
68
|
|
@@ -70,6 +70,22 @@ class Viewpoint::Folder
|
|
70
70
|
end
|
71
71
|
|
72
72
|
|
73
|
+
# unsubscribe from folder
|
74
|
+
# Returns true if unsubscription succeeds, false otherwise
|
75
|
+
def unsubscribe
|
76
|
+
begin
|
77
|
+
if( @subscription_id == nil ) then
|
78
|
+
return true
|
79
|
+
end
|
80
|
+
|
81
|
+
unsub_t = UnsubscribeType.new(@subscription_id)
|
82
|
+
resp = ExchWebServ.instance.ews.unsubscribe(unsub_t).responseMessages.unsubscribeResponseMessage.first
|
83
|
+
|
84
|
+
return (resp.responseCode == "NoError")? true: false
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
73
89
|
# Fetch events with the subscription_id. If one does not exists or is expired,
|
74
90
|
# call subscribe.
|
75
91
|
def check_subscription
|
@@ -79,14 +95,20 @@ class Viewpoint::Folder
|
|
79
95
|
end
|
80
96
|
ge = GetEventsType.new(@subscription_id, @watermark)
|
81
97
|
|
82
|
-
resp = ExchWebServ.instance.ews.getEvents(ge).responseMessages.getEventsResponseMessage
|
98
|
+
resp = ExchWebServ.instance.ews.getEvents(ge).responseMessages.getEventsResponseMessage
|
83
99
|
|
84
100
|
#TODO: Add more event processing
|
85
101
|
|
86
102
|
|
87
|
-
notifications = resp.notification
|
103
|
+
notifications = resp.first.notification
|
88
104
|
|
89
105
|
# Process Notifications
|
106
|
+
if( notifications.copiedEvent != nil)
|
107
|
+
notifications.copiedEvent .each do |note|
|
108
|
+
@watermark = note.watermark
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
90
112
|
if( notifications.createdEvent != nil)
|
91
113
|
notifications.createdEvent.each do |note|
|
92
114
|
@watermark = note.watermark
|
@@ -99,12 +121,24 @@ class Viewpoint::Folder
|
|
99
121
|
end
|
100
122
|
end
|
101
123
|
|
124
|
+
if( notifications.modifiedEvent != nil)
|
125
|
+
notifications.modifiedEvent.each do |note|
|
126
|
+
@watermark = note.watermark
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
102
130
|
if( notifications.movedEvent != nil)
|
103
131
|
notifications.movedEvent.each do |note|
|
104
132
|
@watermark = note.watermark
|
105
133
|
end
|
106
134
|
end
|
107
135
|
|
136
|
+
if( notifications.newMailEvent!= nil)
|
137
|
+
notifications.newMailEvent.each do |note|
|
138
|
+
@watermark = note.watermark
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
108
142
|
if( notifications.statusEvent != nil)
|
109
143
|
notifications.statusEvent.each do |note|
|
110
144
|
@watermark = note.watermark
|
data/lib/viewpoint/item.rb
CHANGED
@@ -43,6 +43,26 @@ class Viewpoint::Item
|
|
43
43
|
end
|
44
44
|
|
45
45
|
|
46
|
+
# Return the OWA ID so we can link to webmail
|
47
|
+
def owa_id
|
48
|
+
vp = ExchWebServ.instance
|
49
|
+
altids_ar = NonEmptyArrayOfAlternateIdsType.new
|
50
|
+
|
51
|
+
altid_t = AlternateIdType.new
|
52
|
+
altid_t.xmlattr_Format = IdFormatType::EwsId
|
53
|
+
altid_t.xmlattr_Id = @item_id
|
54
|
+
altid_t.xmlattr_Mailbox = vp.email
|
55
|
+
altids_ar.alternateId << altid_t
|
56
|
+
|
57
|
+
convertid_t = ConvertIdType.new(altids_ar)
|
58
|
+
convertid_t.xmlattr_DestinationFormat = IdFormatType::OwaId
|
59
|
+
|
60
|
+
resp = vp.ews.convertId(convertid_t)
|
61
|
+
resp.responseMessages.convertIdResponseMessage.first.alternateId.xmlattr_Id
|
62
|
+
#uri = "https://host/owa/?ae=Item&a=open&id=" + owa_id
|
63
|
+
end
|
64
|
+
|
65
|
+
|
46
66
|
# Returns a boolean value, true if the delete ocurred, false otherwise.
|
47
67
|
def delete!
|
48
68
|
@parent_folder.delete_item(@item_id)
|
data/test/test_client.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: viewpoint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Wanek
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-13 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|