| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Elive::Connection::SDK; | 
| 2 | 4 |  |  | 4 |  | 4102 | use warnings; use strict; | 
|  | 4 |  |  | 4 |  | 7 |  | 
|  | 4 |  |  |  |  | 103 |  | 
|  | 4 |  |  |  |  | 15 |  | 
|  | 4 |  |  |  |  | 64 |  | 
|  | 4 |  |  |  |  | 124 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 4 |  |  | 4 |  | 1985 | use Class::Accessor; | 
|  | 4 |  |  |  |  | 6106 |  | 
|  | 4 |  |  |  |  | 21 |  | 
| 5 | 4 |  |  | 4 |  | 127 | use Class::Data::Inheritable; | 
|  | 4 |  |  |  |  | 79 |  | 
|  | 4 |  |  |  |  | 106 |  | 
| 6 | 4 |  |  | 4 |  | 1905 | use HTML::Entities; | 
|  | 4 |  |  |  |  | 18206 |  | 
|  | 4 |  |  |  |  | 415 |  | 
| 7 | 4 |  |  | 4 |  | 29 | use Scalar::Util; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 142 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 4 |  |  | 4 |  | 18 | use Carp; | 
|  | 4 |  |  |  |  | 5 |  | 
|  | 4 |  |  |  |  | 205 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 4 |  |  | 4 |  | 18 | use parent qw{Elive::Connection}; | 
|  | 4 |  |  |  |  | 7 |  | 
|  | 4 |  |  |  |  | 24 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | use Elive; | 
| 14 |  |  |  |  |  |  | use Elive::Util; | 
| 15 |  |  |  |  |  |  | use Elive::Entity; | 
| 16 |  |  |  |  |  |  | use Elive::Entity::User; | 
| 17 |  |  |  |  |  |  | use Elive::Entity::ServerDetails; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =head1 NAME | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | Elive::Connection::SDK - Manage Elluminate Live SDK SOAP connections. | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | This module handles logical connections to Elluminate I sites. | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | Most of the time, you won't need to use this module directly, rather | 
| 28 |  |  |  |  |  |  | you'll create a default connection via L: | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | Elive->connect('https://someserver.com', 'someuser', 'somepass'); | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  | However, if you need to manage multiple sites and/or servers. You can | 
| 33 |  |  |  |  |  |  | have multiple connections: | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | my $connection1 | 
| 36 |  |  |  |  |  |  | = Elive::Connection->connect('https://someserver.com/site1', | 
| 37 |  |  |  |  |  |  | 'user1' => 'pass1', | 
| 38 |  |  |  |  |  |  | timeout => 100, | 
| 39 |  |  |  |  |  |  | ); | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | my $connection2 | 
| 42 |  |  |  |  |  |  | = Elive::Connection->connect('https://user2:pass2@someserver.com/site2'); | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | =cut | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | __PACKAGE__->mk_accessors( qw{_login _server_details} ); | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | our %KnownCommands = ( | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | addGroupMember => 'c', | 
| 51 |  |  |  |  |  |  | addMeetingPreload => 'c', | 
| 52 |  |  |  |  |  |  | addReport => 'c', | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | attendanceNotification => 'r', | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | changePassword => 'u', | 
| 57 |  |  |  |  |  |  |  | 
| 58 |  |  |  |  |  |  | buildMeetingJNLP => 'r', | 
| 59 |  |  |  |  |  |  | buildRecordingJNLP => 'r', | 
| 60 |  |  |  |  |  |  | buildReport => 'r', | 
| 61 |  |  |  |  |  |  |  | 
| 62 |  |  |  |  |  |  | checkMeetingPreload => 'r', | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | createGroup => 'c', | 
| 65 |  |  |  |  |  |  | createMeeting => 'c', | 
| 66 |  |  |  |  |  |  | createPreload => 'c', | 
| 67 |  |  |  |  |  |  | createRecording => 'c', | 
| 68 |  |  |  |  |  |  | createSession => 'c', | 
| 69 |  |  |  |  |  |  | createUser => 'c', | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | deleteGroup => 'd', | 
| 72 |  |  |  |  |  |  | deleteMeeting => 'd', | 
| 73 |  |  |  |  |  |  | deleteMeetingPreload => 'd', | 
| 74 |  |  |  |  |  |  | deleteParticipant => 'd', | 
| 75 |  |  |  |  |  |  | deleteRecording => 'd', | 
| 76 |  |  |  |  |  |  | deleteReport => 'd', | 
| 77 |  |  |  |  |  |  | deletePreload => 'd', | 
| 78 |  |  |  |  |  |  | deleteUser => 'd', | 
| 79 |  |  |  |  |  |  |  | 
| 80 |  |  |  |  |  |  | getGroup => 'r', | 
| 81 |  |  |  |  |  |  | getMeeting => 'r', | 
| 82 |  |  |  |  |  |  | getMeetingParameters => 'r', | 
| 83 |  |  |  |  |  |  | getPreload => 'r', | 
| 84 |  |  |  |  |  |  | getPreloadStream => 'r', | 
| 85 |  |  |  |  |  |  | getRecording => 'r', | 
| 86 |  |  |  |  |  |  | getReport => 'r', | 
| 87 |  |  |  |  |  |  | getRecordingStream => 'r', | 
| 88 |  |  |  |  |  |  | getReport          => 'r', | 
| 89 |  |  |  |  |  |  | getServerDetails => 'r', | 
| 90 |  |  |  |  |  |  | getServerParameters => 'r', | 
| 91 |  |  |  |  |  |  | getUser => 'r', | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | importPreload => 'c', | 
| 94 |  |  |  |  |  |  | importRecording => 'c', | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | isModerator => 'r', | 
| 97 |  |  |  |  |  |  | isParticipant => 'r', | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | listGroups => 'r', | 
| 100 |  |  |  |  |  |  | listMeetingPreloads => 'r', | 
| 101 |  |  |  |  |  |  | listMeetings => 'r', | 
| 102 |  |  |  |  |  |  | listParticipants => 'r', | 
| 103 |  |  |  |  |  |  | listPreloads => 'r', | 
| 104 |  |  |  |  |  |  | listRecordings => 'r', | 
| 105 |  |  |  |  |  |  | listReports => 'r', | 
| 106 |  |  |  |  |  |  | listUserMeetingsByDate => 'r', | 
| 107 |  |  |  |  |  |  | listUsers => 'r', | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | resetGroup => 'u', | 
| 110 |  |  |  |  |  |  | resetParticipantList => 'u', | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | setParticipantList => 'u', | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | streamPreload => 'u', | 
| 115 |  |  |  |  |  |  | streamRecording => 'u', | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | updateGroup => 'u', | 
| 118 |  |  |  |  |  |  | updateMeeting => 'u', | 
| 119 |  |  |  |  |  |  | updateMeetingParameters => 'u', | 
| 120 |  |  |  |  |  |  | updateRecording => 'u', | 
| 121 |  |  |  |  |  |  | updateReport => 'u', | 
| 122 |  |  |  |  |  |  | updateServerParameters => 'u', | 
| 123 |  |  |  |  |  |  | updateSession => 'u', | 
| 124 |  |  |  |  |  |  | updateUser => 'u', | 
| 125 |  |  |  |  |  |  | ); | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | __PACKAGE__->mk_classdata(known_commands => \%KnownCommands); | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | =head2 connect | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | my $ec1 = Elive::Connection::SDK->connect('https://someserver.com/test', | 
| 132 |  |  |  |  |  |  | 'user1', 'pass1', debug => 1); | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | my $url1 = $ec1->url;   #  'https://someserver.com/test' | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | my $ec2 =  Elive::Connection::SDK->connect('http://user2:pass2@someserver.com/test', undef, undef, debug => 1); | 
| 137 |  |  |  |  |  |  | my $url2 = $ec2->url;   #  'http://someserver.com/test' | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | Establishes a SOAP connection over C/C. Retrieves the login user, | 
| 140 |  |  |  |  |  |  | to verify connectivity and authentication details. | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | =cut | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | sub connect { | 
| 145 |  |  |  |  |  |  | my ($class, $url, $user, $pass, %opt) = @_; | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | my $self = $class->_connect($url, $user, $pass, %opt); | 
| 148 |  |  |  |  |  |  | bless $self, $class; | 
| 149 |  |  |  |  |  |  | # | 
| 150 |  |  |  |  |  |  | # The login name should be a valid user in the database. | 
| 151 |  |  |  |  |  |  | # retrieve it as a way of authenticating the user and | 
| 152 |  |  |  |  |  |  | # checking basic connectivity. | 
| 153 |  |  |  |  |  |  | # | 
| 154 |  |  |  |  |  |  | $self->login | 
| 155 |  |  |  |  |  |  | or croak "not logged in"; | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | return $self; | 
| 158 |  |  |  |  |  |  | } | 
| 159 |  |  |  |  |  |  |  | 
| 160 |  |  |  |  |  |  | =head2 disconnect | 
| 161 |  |  |  |  |  |  |  | 
| 162 |  |  |  |  |  |  | Closes a connection and frees any resources related to the connection. | 
| 163 |  |  |  |  |  |  |  | 
| 164 |  |  |  |  |  |  | =cut | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | sub disconnect { | 
| 167 |  |  |  |  |  |  | my $self = shift; | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | $self->SUPER::disconnect; | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | $self->_server_details(undef); | 
| 172 |  |  |  |  |  |  | $self->_login(undef); | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | return; | 
| 175 |  |  |  |  |  |  | } | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  | =head2 soap | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | my $soap_lite_obj = $connection->soap; | 
| 180 |  |  |  |  |  |  |  | 
| 181 |  |  |  |  |  |  | Returns the underlying L object for the connection. | 
| 182 |  |  |  |  |  |  |  | 
| 183 |  |  |  |  |  |  | =cut | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | sub soap { | 
| 186 |  |  |  |  |  |  | my $self = shift; | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | my $soap = $self->_soap; | 
| 189 |  |  |  |  |  |  |  | 
| 190 |  |  |  |  |  |  | unless ($soap) { | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | my $proxy = join('/', $self->url, 'webservice.event'); | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | my $debug = $self->debug; | 
| 195 |  |  |  |  |  |  |  | 
| 196 |  |  |  |  |  |  | SOAP::Lite::import($debug >= 3 | 
| 197 |  |  |  |  |  |  | ? (+trace => 'debug') | 
| 198 |  |  |  |  |  |  | : () | 
| 199 |  |  |  |  |  |  | ); | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | warn "connecting to ".$proxy | 
| 202 |  |  |  |  |  |  | if ($debug); | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | $soap = SOAP::Lite->new(); | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | my %proxy_opts; | 
| 207 |  |  |  |  |  |  | $proxy_opts{timeout} = $self->timeout | 
| 208 |  |  |  |  |  |  | if $self->timeout; | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | $soap->proxy($proxy, %proxy_opts); | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | $self->_soap($soap); | 
| 213 |  |  |  |  |  |  | } | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  | return $soap; | 
| 216 |  |  |  |  |  |  | } | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  | =head2 call | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  | my $som = $self->call( $cmd, %params ); | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | Performs an Elluminate SOAP method call. Returns the response as a | 
| 223 |  |  |  |  |  |  | SOAP::SOM object. | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  | =cut | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | sub call { | 
| 228 |  |  |  |  |  |  | my ($self, $cmd, %params) = @_; | 
| 229 |  |  |  |  |  |  |  | 
| 230 |  |  |  |  |  |  | $params{adapter} ||= 'default'; | 
| 231 |  |  |  |  |  |  |  | 
| 232 |  |  |  |  |  |  | return $self->SUPER::call( $cmd, %params ); | 
| 233 |  |  |  |  |  |  | } | 
| 234 |  |  |  |  |  |  |  | 
| 235 |  |  |  |  |  |  | sub _preamble { | 
| 236 |  |  |  |  |  |  |  | 
| 237 |  |  |  |  |  |  | my ($self,$cmd) = @_; | 
| 238 |  |  |  |  |  |  |  | 
| 239 |  |  |  |  |  |  | die "Not logged in" | 
| 240 |  |  |  |  |  |  | unless ($self->user); | 
| 241 |  |  |  |  |  |  |  | 
| 242 |  |  |  |  |  |  | my @user_auth =  (map {HTML::Entities::encode_entities( $_ )} | 
| 243 |  |  |  |  |  |  | ($self->user, $self->pass)); | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | my @preamble = ( | 
| 246 |  |  |  |  |  |  | (SOAP::Data | 
| 247 |  |  |  |  |  |  | ->name('request') | 
| 248 |  |  |  |  |  |  | ->uri('http://www.soapware.org') | 
| 249 |  |  |  |  |  |  | ->prefix('m') | 
| 250 |  |  |  |  |  |  | ->value('')), | 
| 251 |  |  |  |  |  |  | ); | 
| 252 |  |  |  |  |  |  |  | 
| 253 |  |  |  |  |  |  | push (@preamble, SOAP::Data->name('command')->value($cmd)) | 
| 254 |  |  |  |  |  |  | if $cmd; | 
| 255 |  |  |  |  |  |  |  | 
| 256 |  |  |  |  |  |  | my $auth = sprintf (<<'EOD', @user_auth); | 
| 257 |  |  |  |  |  |  |  | 
| 258 |  |  |  |  |  |  | xmlns:h="http://soap-authentication.org/basic/2001/10/" | 
| 259 |  |  |  |  |  |  | soap:mustUnderstand="1"> | 
| 260 |  |  |  |  |  |  | %s | 
| 261 |  |  |  |  |  |  | %s | 
| 262 |  |  |  |  |  |  |  | 
| 263 |  |  |  |  |  |  | EOD | 
| 264 |  |  |  |  |  |  |  | 
| 265 |  |  |  |  |  |  | return (@preamble, SOAP::Header->type(xml => $auth)); | 
| 266 |  |  |  |  |  |  | }; | 
| 267 |  |  |  |  |  |  |  | 
| 268 |  |  |  |  |  |  | =head2 login | 
| 269 |  |  |  |  |  |  |  | 
| 270 |  |  |  |  |  |  | Returns the login user as an object of type L. | 
| 271 |  |  |  |  |  |  |  | 
| 272 |  |  |  |  |  |  | =cut | 
| 273 |  |  |  |  |  |  |  | 
| 274 |  |  |  |  |  |  | sub login { | 
| 275 |  |  |  |  |  |  | my ($self) = @_; | 
| 276 |  |  |  |  |  |  |  | 
| 277 |  |  |  |  |  |  | my $login_entity = $self->_login; | 
| 278 |  |  |  |  |  |  |  | 
| 279 |  |  |  |  |  |  | unless ($login_entity) { | 
| 280 |  |  |  |  |  |  |  | 
| 281 |  |  |  |  |  |  | my $username = $self->user | 
| 282 |  |  |  |  |  |  | or return; | 
| 283 |  |  |  |  |  |  |  | 
| 284 |  |  |  |  |  |  | $login_entity = Elive::Entity::User->get_by_loginName($username, | 
| 285 |  |  |  |  |  |  | connection => $self) | 
| 286 |  |  |  |  |  |  | or die "unable to get login user: $username\n"; | 
| 287 |  |  |  |  |  |  |  | 
| 288 |  |  |  |  |  |  | $self->_login($login_entity); | 
| 289 |  |  |  |  |  |  | } | 
| 290 |  |  |  |  |  |  |  | 
| 291 |  |  |  |  |  |  | return $login_entity; | 
| 292 |  |  |  |  |  |  | } | 
| 293 |  |  |  |  |  |  |  | 
| 294 |  |  |  |  |  |  | =head2 server_details | 
| 295 |  |  |  |  |  |  |  | 
| 296 |  |  |  |  |  |  | Returns the server details as an object of type L. | 
| 297 |  |  |  |  |  |  |  | 
| 298 |  |  |  |  |  |  | =cut | 
| 299 |  |  |  |  |  |  |  | 
| 300 |  |  |  |  |  |  | sub server_details { | 
| 301 |  |  |  |  |  |  | my $self = shift; | 
| 302 |  |  |  |  |  |  |  | 
| 303 |  |  |  |  |  |  | my $server_details = $self->_server_details; | 
| 304 |  |  |  |  |  |  |  | 
| 305 |  |  |  |  |  |  | unless ($server_details) { | 
| 306 |  |  |  |  |  |  |  | 
| 307 |  |  |  |  |  |  | $server_details = Elive::Entity::ServerDetails->list(connection => $self); | 
| 308 |  |  |  |  |  |  | $self->_server_details($server_details); | 
| 309 |  |  |  |  |  |  | } | 
| 310 |  |  |  |  |  |  |  | 
| 311 |  |  |  |  |  |  | # | 
| 312 |  |  |  |  |  |  | # this site could be running multiple servers | 
| 313 |  |  |  |  |  |  | # | 
| 314 |  |  |  |  |  |  |  | 
| 315 |  |  |  |  |  |  | return wantarray ? @$server_details : $server_details->[0]; | 
| 316 |  |  |  |  |  |  | } | 
| 317 |  |  |  |  |  |  |  | 
| 318 |  |  |  |  |  |  | =head2 version | 
| 319 |  |  |  |  |  |  |  | 
| 320 |  |  |  |  |  |  | Return the Elluminate I Server version | 
| 321 |  |  |  |  |  |  |  | 
| 322 |  |  |  |  |  |  | =cut | 
| 323 |  |  |  |  |  |  |  | 
| 324 |  |  |  |  |  |  | sub version { | 
| 325 |  |  |  |  |  |  | my $self = shift; | 
| 326 |  |  |  |  |  |  | my $server_details = $self->server_details | 
| 327 |  |  |  |  |  |  | or die "Unable to get server details. Are all services running?\n"; | 
| 328 |  |  |  |  |  |  | return $server_details->version; | 
| 329 |  |  |  |  |  |  | } | 
| 330 |  |  |  |  |  |  |  | 
| 331 |  |  |  |  |  |  | 1; |