Advertisement
Guest User

stupid

a guest
Sep 1st, 2010
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.45 KB | None | 0 0
  1. //integer PRIM_GLOW = 25;
  2. integer steps = 2;
  3. integer counter = 0;
  4. vector my_position = <0,0,0>;
  5. string api_url = "http://www.bhr.vivox.com/api2/";
  6. string access_code = "787705"; // set me to 0 on production model, default access code for now
  7. string dial_in_number = "1-301-789-0017";
  8. string cur_state = "disabled";
  9. string cur_channel = "";
  10.  
  11. //war was begining
  12. integer SL_COM_CHANNEL = 2101;
  13.  
  14. //Admin login
  15. string userid = "viv_hud_admin";
  16. string pwd = "vivox123";
  17. string auth_token = "";
  18.  
  19. // HTTP request variables
  20. // number of items in stored http requests
  21. integer requestStrideLength = 4; // request id, user, request type,request
  22. // identifier for a unique http request
  23. key requestid;
  24. // list of active http requests
  25. list requestList;
  26.  
  27.  
  28. //Object Display
  29. vector color_on = <0,1,0>;
  30. vector color_off = <1,0,0>;
  31.  
  32. //user info
  33. string agent = "";
  34. string username = "";
  35.  
  36. init_access()
  37. {
  38. llOwnerSay("verifying access");
  39.  
  40. agent = (string)llGetOwner();
  41. mangle_uuid(agent);
  42.  
  43. string result;
  44. string request = api_url+"viv_signin.php?userid="+userid+"&pwd="+pwd;
  45. result = llHTTPRequest(request, [HTTP_METHOD,"GET"],"");
  46.  
  47. //llOwnerSay("access result = " + result);
  48.  
  49. //llOwnerSay("checking and setting cur font id");
  50.  
  51. request = api_url+"viv_acct.php?username="+username+"&mode=update&auth_token="+auth_token;
  52. //http://www.bhd.vivox.com/api2/viv_acct.php?username=xNjm8h8bgRLePQgqafhaCqw==&font_default=37&mode=update&userid=viv_hud_admin&pwd=vivox123
  53. result = llHTTPRequest(request, [HTTP_METHOD,"GET"],"");
  54.  
  55. vivox_channel();
  56. my_position = vivox_coords();
  57.  
  58. }
  59.  
  60. mangle_uuid(string acctname) {
  61. string result;
  62. string request = "http://vir5ag.vivox.com/dave/jon/sl/mangle_uuid.php?uuid=" + agent; //Move this file and change me please!
  63. result = llHTTPRequest(request, [HTTP_METHOD,"GET"],"");
  64. }
  65.  
  66. vector vivox_coords()
  67. {
  68. vector vivox_coords;
  69. vector vregion = llGetRegionCorner();
  70. vector vlocal = llGetPos();
  71.  
  72. vivox_coords.x = vregion.x + vlocal.x;
  73. vivox_coords.z = -(vregion.y + vlocal.y);
  74. vivox_coords.y = 30;
  75.  
  76. llOwnerSay((string)vivox_coords);
  77.  
  78. return vivox_coords;
  79. }
  80.  
  81. vivox_channel()
  82. {
  83. //TODO: this shouldn't commented out, it needs to be fixed!
  84. //string result;
  85. //string request = api_url+"viv_chan_cmd.php?mode=find_user&extended=1&user_name="+username+"auth_token="+auth_token;
  86. //result = llHTTPRequest(request, [HTTP_METHOD,"GET"],"");
  87.  
  88. string region = llGetRegionName();
  89. if(region == "Suzume")
  90. {
  91. cur_channel = "sip:confctl-40358127@bhr.vivox.com";
  92. }
  93.  
  94. if(region == "Ambrosia")
  95. {
  96. cur_channel = "sip:confctl-6481071@bhr.vivox.com";
  97. }
  98. if(region == "Linden Estate Services" || region == "Linden Estate Services4")
  99. {
  100. cur_channel = "sip:confctl-55696976@bhr.vivox.com";
  101. }
  102.  
  103. }
  104.  
  105. //set_font(string fid)
  106. //{
  107. //llOwnerSay("Setting Font ID now...");
  108.  
  109. //if(fid == cur_font_id)
  110. //{ return; }
  111. //string result;
  112. //string request = api_url+"viv_acct.php?username="+username+"&font_default="+fid+"&mode=update&auth_token="+auth_token;
  113. //http://www.bhd.vivox.com/api2/viv_acct.php?username=xNjm8h8bgRLePQgqafhaCqw==&font_default=37&mode=update&userid=viv_hud_admin&pwd=vivox123
  114. //result = llHTTPRequest(request, [HTTP_METHOD,"GET"],"");
  115.  
  116. //llOwnerSay("Request token: " + result);
  117.  
  118. //}
  119.  
  120. Activate_Speakerphone(vector location, string code)
  121. {
  122. if(code == "" || code == "0")
  123. {
  124. // object not initialized with an access code, throw error/message user to buy an access code
  125. llOwnerSay("Looks like you don't have an access code set, you should probably fix that!");
  126. }
  127.  
  128. if(location.x != 0.0 && location.z != 0.0)
  129. {
  130. //hey, new location set
  131. string result;
  132. string request = api_url+"viv_adm_access_code_activation.php?mode=activate&code="+code+"&x_pos="+(string)location.x+"&y_pos=30.00000&z_pos="+(string)location.z+"&chan_uri="+cur_channel+"&auth_token="+auth_token;
  133. result = llHTTPRequest(request, [HTTP_METHOD,"GET"], "");
  134. }
  135. else{
  136. // we're just turning it back on, don't move it
  137. string result;
  138. string request = api_url+"viv_adm_access_code_activation.php?mode=activate&code="+code+"&auth_token="+auth_token;
  139. result = llHTTPRequest(request, [HTTP_METHOD,"GET"], "");
  140. }
  141. }
  142. Deactivate_Speakerphone(string code)
  143. {
  144. string result;
  145. string request = api_url+"viv_adm_access_code_activation.php?mode=activate&code="+code+"&auth_token="+auth_token;
  146. result = llHTTPRequest(request, [HTTP_METHOD,"GET"], "");
  147. }
  148.  
  149. // return the value for the passed xml element
  150. // returns the first instance of the element found
  151. // method currently fails to find element if passed element contains attributes
  152. string getXMLValue(string xmlstring, string element)
  153. {
  154. // llOwnerSay("getxmlvalue ...element: " + element + ", xmlstring: " + xmlstring);
  155. string value = "";
  156. string elementopen = "<" + element + ">";
  157. string elementclose = "</" + element + ">";
  158. integer elementstart = llSubStringIndex(xmlstring, elementopen);
  159. if(elementstart == -1){
  160. // element not found
  161. // llOwnerSay("did not find " + element + " in xml");
  162. return NULL_KEY;
  163. }
  164. integer valuestart = elementstart + llStringLength(elementopen);
  165. integer valueend = llSubStringIndex(xmlstring, elementclose) - 1;
  166. value = llGetSubString(xmlstring, valuestart, valueend);
  167. // llOwnerSay("found value = " + value);
  168. return value;
  169. }
  170.  
  171. Set_Display(string message, vector color)
  172. {
  173. llSetText(message, color, 1); //Update display
  174. }
  175.  
  176. default
  177. {
  178. on_rez(integer start_param)
  179. {
  180. //reset object
  181. llResetScript();
  182. llOwnerSay((string)vivox_coords());
  183.  
  184. //get the auth token
  185. init_access();
  186.  
  187.  
  188.  
  189.  
  190. //get the user's access code, when that functionality comes along
  191.  
  192. //get the objects coordinates and set them
  193. my_position = vivox_coords();
  194.  
  195. //set state to off and reset object
  196. cur_state = "disabled";
  197. Set_Display("Not Broadcasting", color_off);
  198. llWhisper(0, "Thanks for using the Vivox dial-in speakerphone! Touch me to get started.");
  199.  
  200.  
  201.  
  202.  
  203. }
  204.  
  205. state_entry()
  206. {
  207. //Set up listens for HUD control
  208. llListen(SL_COM_CHANNEL, "", "", ""); //This can be imrpoved, but for the moment this will work
  209. init_access();
  210. }
  211.  
  212.  
  213. listen( integer channel, string name, key id, string message )
  214. {
  215. if(auth_token == "")
  216. {
  217. //llOwnerSay("calling init access");
  218. init_access();
  219. }
  220.  
  221. if(message == "SPEAKERPHONE")
  222. {
  223. if(cur_state == "enabled")
  224. {
  225. Activate_Speakerphone(my_position, access_code);
  226. Set_Display("Not Broadcasting", color_off);
  227. llWhisper(0, "Speakerphone disabled to new calls");
  228. cur_state = "disabled";
  229. }
  230. else if(cur_state == "disabled")
  231. {
  232. Activate_Speakerphone(my_position, access_code);
  233. Set_Display("(((Broadcasting ON)))", color_on);
  234. llWhisper(0, "Speakerphone enabled, your conversations can be heard!");
  235. llWhisper(0, "To dial in, call " + dial_in_number + " with access code " + access_code);
  236. cur_state = "enabled";
  237. }
  238. }
  239. }
  240.  
  241. touch_start(integer total_number)
  242. {
  243. if(auth_token == "")
  244. {
  245. //llOwnerSay("calling init access");
  246. init_access();
  247. }
  248.  
  249. if(cur_state == "enabled")
  250. {
  251. Activate_Speakerphone(my_position, access_code);
  252. Set_Display("Not Broadcasting", color_off);
  253. llWhisper(0, "Speakerphone disabled to new calls");
  254. cur_state = "disabled";
  255. }
  256. else if(cur_state == "disabled")
  257. {
  258. Activate_Speakerphone(my_position, access_code);
  259. Set_Display("(((Broadcasting ON)))", color_on);
  260. llWhisper(0, "Speakerphone enabled, your conversations can be heard!" + " Position = " + (string)my_position);
  261. llWhisper(0, "To dial in, call " + dial_in_number + " with access code " + access_code);
  262. cur_state = "enabled";
  263. }
  264.  
  265. //llOwnerSay("Auth Token: " + auth_token);
  266.  
  267.  
  268. //llSetPrimitiveParams( [ PRIM_GLOW, ALL_SIDES, counter/ (steps - 1.0) ] );
  269. //if setting to on, set message to on and whisper dial in info
  270.  
  271. //else set it to off
  272.  
  273.  
  274. }
  275.  
  276. //http_response is called when llHTTPRequest is called
  277. http_response(key request_id, integer status, list metadata, string body)
  278. {
  279. integer i;
  280. // find the request entry corresponding to this response
  281. integer requestIndex = llListFindList(requestList, [request_id]);
  282. list requestEntry = llList2List(requestList, requestIndex, requestStrideLength);
  283.  
  284. //hey we got an auth_token, update it
  285. if(getXMLValue(body, "auth_token") != NULL_KEY)
  286. {
  287. auth_token = getXMLValue(body, "auth_token");
  288. //TODO: remove debug
  289. //llOwnerSay("Auth Token: " + auth_token);
  290. }
  291. //hey we got a font id, update it
  292.  
  293. //hey we got a translated user, update it
  294. if(getXMLValue(body, "translated_username") != NULL_KEY)
  295. {
  296. username = getXMLValue(body, "translated_username");
  297. //llOwnerSay((string)username);
  298. }
  299.  
  300. // check the response body for an error code
  301. if ( ( i = llSubStringIndex(body,"ERR") ) != -1 ){
  302. //llWhisper(0, "An error occurred on a http request");
  303. //llWhisper(0, "Request was " + llList2String(requestEntry, 3));
  304. // llWhisper(0, "Response was " + body);
  305. llOwnerSay("Something didn't happen as expected! Try again, but if this problem persists contact a member of the Vivox Second Life group with a description of the problem " + (string)my_position);
  306.  
  307. string code = getXMLValue(body, "code");
  308. string msg = getXMLValue(body, "msg");
  309.  
  310. }
  311. }
  312.  
  313. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement