Class: TokBoxer::User

Inherits:
Object
  • Object
show all
Defined in:
lib/TokBoxer/User.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jabberId, secret, api) ⇒ User



8
9
10
11
12
13
# File 'lib/TokBoxer/User.rb', line 8

def initialize(jabberId, secret, api)
  @jabberId = jabberId
  @secret = secret
  @api = api
  self.
end

Instance Attribute Details

#jabberIdObject (readonly) Also known as: id

Returns the value of attribute jabberId.



5
6
7
# File 'lib/TokBoxer/User.rb', line 5

def jabberId
  @jabberId
end

#secretObject (readonly)

Returns the value of attribute secret.



5
6
7
# File 'lib/TokBoxer/User.rb', line 5

def secret
  @secret
end

Instance Method Details

#access_token_valid?Boolean



36
37
38
39
# File 'lib/TokBoxer/User.rb', line 36

def access_token_valid?
  result = @api.validate_access_token(@jabberId, @secret)
  result['validateAccessToken'].first["isValid"].first == "true"
end

#create_call(full_name, persistent = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/TokBoxer/User.rb', line 22

def create_call(full_name,persistent=false)
  result = @api.create_call(@jabberId, full_name, persistent)
  if result['createCall'] and (createCall=result['createCall'].first)
    Call.new createCall['callerName'],
             createCall['callId'].first,
             createCall['callerJabberId'],
             createCall['persistent'],
             createCall['server'].first,
             @api
  else
    nil
  end
end

#display_nameObject



113
114
115
# File 'lib/TokBoxer/User.rb', line 113

def display_name
  info["displayName"].first
end

#is_online?Boolean



109
110
111
# File 'lib/TokBoxer/User.rb', line 109

def is_online?
  info["isOnline"].first == "true"
end

#loginObject

TODO add a method which calls get_request_token from the API to get the jabberId and secret from the email and password



18
19
20
# File 'lib/TokBoxer/User.rb', line 18

def 
  @api.(self.jabberId,self.secret)
end

#player_embed_code(messageId, width = "425", height = "344") ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/TokBoxer/User.rb', line 89

def player_embed_code(messageId, width="425", height="344")
  <<-END
  <object width="#{width}" height="#{height}">

    <param name="movie" value="#{@api.api_server_url}#{API_SERVER_PLAYER_WIDGET}"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowScriptAccess" value="true"></param>
    <embed id="tbx_player" src="#{@api.api_server_url}#{API_SERVER_PLAYER_WIDGET}"
      type="application/x-shockwave-flash"
      allowfullscreen="true"
      allowScriptAccess="always"
      flashvars="targetVmail=#{messageId}"
      width="#{width}" 
      height="#{height}"
    >
    </embed>
  </object>
  END
end

#received_vmailsObject



55
56
57
58
59
# File 'lib/TokBoxer/User.rb', line 55

def received_vmails
  @api.get_feed(@jabberId,"vmailRecv")["feed"].first["item"].map do |m|
    VMail.new m["videoMail"].first["content"]["messageId"].first
  end
end

#recorder_embed_code(width = "322", height = "321", vmailToEmail = "") ⇒ Object



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
86
87
# File 'lib/TokBoxer/User.rb', line 61

def recorder_embed_code(width="322", height="321",vmailToEmail="")
  # TODO: this comes from the PHP api. Not yet implemented here
  # if($isGuest) {
  #   $apiObj = new TokBoxApi(API_Config::PARTNER_KEY, API_Config::PARTNER_SECRET);
  #   $apiObj->updateToken($apiObj->getRequestToken(API_Config::CALLBACK_URL));
  # 
  #   $htmlCode .= "<script language=\"javascript\" src=\"SDK/js/TokBoxScript.js\"></script>\n";
  #   $htmlCode .= "<body onclick=\"setToken('".$apiObj->getAuthToken()."');\">\n";     
  # }
  <<-END
  <object width="#{width}" height="#{height}">
    <param name="movie" value="#{@api.api_server_url}#{API_SERVER_RECORDER_WIDGET}"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowScriptAccess" value="true"></param>
    <param name="FlashVars" value="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}&offsiteAuth=true&vmailToEmail=#{vmailToEmail}"></param>
    <embed id="tbx_recorder" src="#{@api.api_server_url}#{API_SERVER_RECORDER_WIDGET}"
      type="application/x-shockwave-flash"
      allowfullscreen="true"
      allowScriptAccess="always"
      width="#{width}"
      height="#{height}"
      FlashVars="tokboxPartnerKey=#{@api.api_key}&tokboxJid=#{jabberId}&tokboxAccessSecret=#{secret}&offsiteAuth=true&vmailToEmail=#{vmailToEmail}"
    >
    </embed>
  </object>
  END
end

#sent_vmailsObject



49
50
51
52
53
# File 'lib/TokBoxer/User.rb', line 49

def sent_vmails
  @api.get_feed(@jabberId,"vmailSent")["feed"].first["item"].map do |m|
    VMail.new m["videoMail"].first["content"]["messageId"].first
  end
end

#showObject



125
126
127
# File 'lib/TokBoxer/User.rb', line 125

def show
  info["show"].first
end

#useridObject



121
122
123
# File 'lib/TokBoxer/User.rb', line 121

def userid
  info["userid"].first
end

#usernameObject



117
118
119
# File 'lib/TokBoxer/User.rb', line 117

def username
  info["username"].first
end

#vmailsObject

Feeds ============================================================================================



43
44
45
46
47
# File 'lib/TokBoxer/User.rb', line 43

def vmails
  @api.get_feed(@jabberId,"all")["feed"].first["item"].map do |m|
    VMail.new m["videoMail"].first["content"]["messageId"].first
  end
end