org.symbian.tools.wrttools.previewer/preview/script/helper.js
changeset 402 f943a50b6689
child 403 ba20dd5983c7
equal deleted inserted replaced
400:91acf7e95f86 402:f943a50b6689
       
     1 function EmulatorHelper() {
       
     2 	this.path = document.location.pathname;
       
     3 	this.errorDailog = null;
       
     4 	this.prefDailog = null;
       
     5 	this.inspectorDailog = null;
       
     6 	this.intervalId = null;
       
     7 	this.infoPlistCounter = false;
       
     8 	this.IconFileCounter = false;
       
     9 }
       
    10 
       
    11 EmulatorHelper.prototype.loadScript = function(path) {
       
    12 	var head = document.getElementsByTagName("head")[0]
       
    13 			|| document.documentElement;
       
    14 	var script = document.createElement("script");
       
    15 
       
    16 	script.type = "text/javascript";
       
    17 	script.src = src;
       
    18 	head.appendChild(script);
       
    19 };
       
    20 
       
    21 EmulatorHelper.prototype.loadPreferences = function() {
       
    22 	if (/dreamweaver/i.test(navigator.userAgent)) {
       
    23 		$("#dwDeviceHelp")[0].className = '';
       
    24 		// $("#resSupportLink")[0].className = 'hide';
       
    25 	}
       
    26 	// Selecting Resoltion
       
    27 	var resOptions = $("#resOptions")[0];
       
    28 	for ( var i = 0; i < NOKIA.resolution.length; i++) {
       
    29 		if (NOKIA.resolution[i] == NOKIA.currentDevice) {
       
    30 			resOptions.options[i].selected = true;
       
    31 			break;
       
    32 		}
       
    33 	}
       
    34 
       
    35 	// Selecting Version
       
    36 	if (NOKIA.version == 'WRT 1.0')
       
    37 		$('#wrt_version_1_0')[0].checked = true;
       
    38 	else
       
    39 		$('#wrt_version_1_1')[0].checked = true;
       
    40 
       
    41 	// HomeScreen Support
       
    42 	if (NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport) {
       
    43 		if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
       
    44 			if (NOKIA.emulator.plist.MiniViewEnabled == 'false')
       
    45 				$('#HS_Control_Info')
       
    46 						.html(
       
    47 								"<span id='wrt-help' onclick='javascipt:NOKIA.helper.showMiniviewHelp();'></span><strong>Not Enabled</strong><br/><small>Click on help to read more about enabling Mini view support</small>");
       
    48 			else
       
    49 				$('#HS_Control_Info').html("Supported");
       
    50 		} else
       
    51 			$('#HS_Control_Info').html(
       
    52 					"<span id='wrt-help'></span>Not Supported");
       
    53 
       
    54 		$('#HS_Control_Info').show();
       
    55 
       
    56 	} else {
       
    57 		$('#HS_Control_Info').html(
       
    58 				"Not Supported for the selected Device resolution");
       
    59 		$('#HS_Control_Info').show();
       
    60 	}
       
    61 };
       
    62 
       
    63 EmulatorHelper.prototype.getInfo = function(url, callback) {
       
    64 	try {
       
    65 		var xhr = this.ajax();
       
    66 
       
    67 		if ((/AppleWebKit/i.test(navigator.userAgent)))
       
    68 			xhr.open("GET", url, false);
       
    69 		else
       
    70 			xhr.open("GET", url, true);
       
    71 
       
    72 		xhr.onreadystatechange = function() {
       
    73 			// readyState = 4 ; "complete"
       
    74 			if (xhr.readyState == 4) {
       
    75 				// status = 200 ; "ok"
       
    76 				if ((xhr.status == 200) || (!xhr.status)) {
       
    77 					callback(true, xhr);
       
    78 				} else {
       
    79 					callback(false, xhr);
       
    80 				}
       
    81 			}
       
    82 
       
    83 		};
       
    84 		xhr.send(null);
       
    85 	} catch (e) {
       
    86 		if (e.name == 'NS_ERROR_FILE_NOT_FOUND') {
       
    87 			callback(false, xhr);
       
    88 		}
       
    89 	}
       
    90 };
       
    91 
       
    92 EmulatorHelper.prototype.getInfoCallback = function(flag, xhr) {
       
    93 	// If Info.plis NOT FOUND / FAILED LOAD
       
    94 	// an ERROR!, unable to proceed further
       
    95 	// STOP there
       
    96 	if (!flag) {
       
    97 		if (!NOKIA.helper.infoPlistCounter) {
       
    98 			NOKIA.helper.infoPlistCounter = true;
       
    99 			NOKIA.helper.getInfo('info.plist', NOKIA.helper.getInfoCallback);
       
   100 			return false;
       
   101 		}
       
   102 
       
   103 		NOKIA.helper
       
   104 				.error('WRT Previewer: Initialization failed. Could not open Info.plist file.<br/>Please ensure <strong style="color:#efe352;">Info.plist</strong> file exists in the project root folder and that it is named properly.');
       
   105 		return false;
       
   106 	} else {
       
   107 
       
   108 		var xmlString = xhr.responseText;
       
   109 
       
   110 		// do some cheating here
       
   111 		xmlString = xmlString.replace(/<!--(.|[\n\r])*?-->/gm, "");
       
   112 		xmlString = xmlString.replace(/<\s*true\s*\/>/gi,
       
   113 				"<string>true</string>");
       
   114 		xmlString = xmlString.replace(/<\s*false\s*\/>/gi,
       
   115 				"<string>false</string>");
       
   116 		xmlString = xmlString.replace(/[\n\r]/gi, "");
       
   117 		// return the JSON Object
       
   118 		NOKIA.helper.validate(xmlString);
       
   119 	}
       
   120 };
       
   121 
       
   122 EmulatorHelper.prototype.getIconCallback = function(flag, xhr) {
       
   123 
       
   124 	if (!flag) {
       
   125 		if (!NOKIA.helper.IconFileCounter) {
       
   126 			NOKIA.helper.IconFileCounter = true;
       
   127 			NOKIA.helper.getInfo('icon.png', NOKIA.helper.getIconCallback);
       
   128 			return false;
       
   129 		}
       
   130 	} else
       
   131 		NOKIA.emulator.iconFile = (NOKIA.helper.IconFileCounter) ? "icon.png"
       
   132 				: "Icon.png";
       
   133 };
       
   134 
       
   135 EmulatorHelper.prototype.validate = function(xmlObject) {
       
   136 	var values = xmlObject
       
   137 			.match(/.*<plist.*?(<dict.*?>\s*(<key[^>]*?>[^<]*?<\/key>\s*<string[^>]*?>[^<]*?<\/string>)*\s*<\/dict>)\s*<\/plist>/)[1];
       
   138 	if (values == null || values == undefined) {
       
   139 		NOKIA.helper.error('Corrupted Info.plist file');
       
   140 		return false;
       
   141 	}
       
   142 	values = values.replace(/<dict.*?(<key.*?>\s*.*\s*<\/string>)\s*<\/dict>/,
       
   143 			"{ $1 }");
       
   144 	values = values
       
   145 			.replace(
       
   146 					/\s*<key.*?>\s*(.*?)\s*<\/key>\s*<string.*?>\s*(.*?)\s*<\/string>\s*/g,
       
   147 					"\"$1\" : \"$2\", ");
       
   148 	values = values.replace(/"\s*?,\s*?}/g, "\" }");
       
   149 	try {
       
   150 		NOKIA.emulator.plist = JSON.parse(values);
       
   151 	} catch (exception) {
       
   152 		NOKIA.helper.error('Corrupted Info.plist file');
       
   153 		return false;
       
   154 	}
       
   155 
       
   156 	try {
       
   157 		if (typeof NOKIA.emulator.plist.DisplayName != 'undefined') {
       
   158 			document.title = NOKIA.emulator.plist.DisplayName + ' - '
       
   159 					+ document.title;
       
   160 		}
       
   161 	} catch (e) {
       
   162 	}
       
   163 
       
   164 	// Add UI-Event listeners
       
   165 	NOKIA.helper.addListeners();
       
   166 	NOKIA.layout.init();
       
   167 	NOKIA.emulator.render();
       
   168 };
       
   169 
       
   170 EmulatorHelper.prototype.ajax = function() {
       
   171 	// xmlHttpRequest object
       
   172 	var request = null;
       
   173 
       
   174 	// branch for native XMLHttpRequest object
       
   175 	if (window.XMLHttpRequest && !(window.ActiveXObject)) {
       
   176 		try {
       
   177 			request = new XMLHttpRequest();
       
   178 			try {
       
   179 				// attach the Bypass code, if the browser is firefox
       
   180 				if (netscape.security.PrivilegeManager.enablePrivilege) {
       
   181 					// duplicate the function
       
   182 					request._open = request.open;
       
   183 
       
   184 					// redefine the function definition
       
   185 					request.open = function(method, url, flag) {
       
   186 						try {
       
   187 							// Enable Universal Browser Read
       
   188 							netscape.security.PrivilegeManager
       
   189 									.enablePrivilege("UniversalBrowserRead");
       
   190 
       
   191 							// call the native XmlHttpRequest.open method
       
   192 							this._open(method, url, flag);
       
   193 						} catch (e) {
       
   194 							// call the native XmlHttpRequest.open method
       
   195 							this._open(method, url, flag);
       
   196 						}
       
   197 					};
       
   198 				}
       
   199 			} catch (e) {
       
   200 				// eatup all exceptions
       
   201 			}
       
   202 		} catch (e) {
       
   203 			request = null;
       
   204 		}
       
   205 		// branch for IE/Windows ActiveX version
       
   206 	} else if (window.ActiveXObject) {
       
   207 		try {
       
   208 			request = new ActiveXObject("Msxml2.XMLHTTP");
       
   209 		} catch (e) {
       
   210 			try {
       
   211 				request = new ActiveXObject("Microsoft.XMLHTTP");
       
   212 			} catch (e) {
       
   213 				alert('Failed to create XmlHttprequest');
       
   214 				return null;
       
   215 			}
       
   216 		}
       
   217 	}
       
   218 
       
   219 	return (request);
       
   220 };
       
   221 
       
   222 EmulatorHelper.prototype.error = function(msg) {
       
   223 	if (NOKIA.menu.enable_log)
       
   224 		NOKIA.layout.log("log", msg);
       
   225 
       
   226 	$("#Dialog").html(msg);
       
   227 	$("#Dialog").dialog('open');
       
   228 };
       
   229 
       
   230 EmulatorHelper.prototype.setPreference = function(name, value) {
       
   231 	if (NOKIA.emulator.prefs[name] != value) {
       
   232 		NOKIA.emulator.prefs[name] = value;
       
   233 		$.post("preview/preferences.js", JSON.stringify( {
       
   234 			"key" : name,
       
   235 			"value" : value
       
   236 		}), undefined, "json");
       
   237 	}
       
   238 };
       
   239 
       
   240 EmulatorHelper.prototype.getPreference = function(name) {
       
   241 	return NOKIA.emulator.prefs[name];
       
   242 };
       
   243 
       
   244 EmulatorHelper.prototype.rotateCW = function() {
       
   245 	var newOrient = NOKIA.orientation + 90;
       
   246 	NOKIA.emulator.toggle(newOrient - (newOrient > 180 ? 360 : 0));
       
   247 };
       
   248 
       
   249 EmulatorHelper.prototype.rotateCCW = function() {
       
   250 	var newOrient = NOKIA.orientation - 90;
       
   251 	NOKIA.emulator.toggle(newOrient + (newOrient <= -180 ? 360 : 0));
       
   252 };
       
   253 
       
   254 EmulatorHelper.prototype.version = function(ele) {
       
   255 	if (confirm('Would you like to reload the widget to apply the changes on the Version settings?')) {
       
   256 		NOKIA.helper.setPreference('__SYM_WRT_VERSION', ele.value);
       
   257 		$("#loaderDiv").html("Applying the " + ele.value + ", please wait...");
       
   258 		$("#loaderDiv").show();
       
   259 		$("#loaderDiv")[0].className = 'green';
       
   260 
       
   261 		window.setTimeout(function() {
       
   262 			document.location = document.location;
       
   263 		}, 3000);
       
   264 	} else {
       
   265 		ele.checked = false;
       
   266 		if (ele.value != 'WRT 1.0')
       
   267 			$("#wrt_version_1_0")[0].checked = true;
       
   268 		else
       
   269 			$("#wrt_version_1_1")[0].checked = true;
       
   270 	}
       
   271 };
       
   272 
       
   273 EmulatorHelper.prototype.addListeners = function() {
       
   274 	NOKIA.helper.loadPreferences();
       
   275 	/*
       
   276 	 * Render Emulator for Interaction
       
   277 	 */
       
   278 	NOKIA.helper.inspectorDailog = $("#InspectorTab").dialog( {
       
   279 		width : 370,
       
   280 		minWidth : 300,
       
   281 		minHeight : 200,
       
   282 		height : 250,
       
   283 		autoOpen : false,
       
   284 		position : top,
       
   285 		title : '&nbsp;',
       
   286 		buttons : {
       
   287 			"Close" : function() {
       
   288 				$("#InspectorTab").dialog('close');
       
   289 			},
       
   290 			"Disconnect Debugger" : function() {
       
   291 				$.ajax( {
       
   292 					url : "__sym_command/terminateDebug"
       
   293 				});
       
   294 			}
       
   295 		}
       
   296 	});
       
   297 
       
   298 	$('#InspectorBtn').click(function() {
       
   299 		$('#InspectorTab').dialog('open');
       
   300 		// Hack for Mac firefox
       
   301 		if (/Mac/i.test(navigator.userAgent)) {
       
   302 			$("#WidgetArea iframe").css( {
       
   303 				overflow : 'hidden'
       
   304 			});
       
   305 		}
       
   306 	});
       
   307 
       
   308 	$('#rotateCW').click(function() {
       
   309 		NOKIA.helper.rotateCW();
       
   310 	});
       
   311 	$('#rotateCCW').click(function() {
       
   312 		NOKIA.helper.rotateCCW();
       
   313 	});
       
   314 	$('#resOptions').change(
       
   315 			function(ele) {
       
   316 				ele = ele.target || this;
       
   317 
       
   318 				NOKIA.currentDevice = ele.options[ele.selectedIndex].text;
       
   319 
       
   320 				// SAVE the device DATA
       
   321 				NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE',
       
   322 						NOKIA.currentDevice);
       
   323 
       
   324 				NOKIA.emulator.render();
       
   325 				NOKIA.helper.loadPreferences();
       
   326 			});
       
   327 
       
   328 	// Hack for Mac firefox
       
   329 	if (/Mac/i.test(navigator.userAgent)) {
       
   330 		if (!(/AppleWebKit/i.test(navigator.userAgent))) {
       
   331 			$("#resOptions")[0].size = '4';
       
   332 		}
       
   333 	}
       
   334 
       
   335 	// WRT Version controls
       
   336 	$('#wrt_version_1_0').change(function() {
       
   337 		NOKIA.helper.version(this);
       
   338 	});
       
   339 
       
   340 	$('#wrt_version_1_1').change(function() {
       
   341 		NOKIA.helper.version(this);
       
   342 	});
       
   343 
       
   344 	$("#orientationIcon").click(function() {
       
   345 		var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
       
   346 		NOKIA.emulator.setMode(mode);
       
   347 		$("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
       
   348 	});
       
   349 
       
   350 	$("#iframeMask").click(function() {
       
   351 		$("#orientationIcon").hide();
       
   352 		$("#iframeMask").hide();
       
   353 		$("#loaderDiv").hide();
       
   354 
       
   355 		NOKIA.menu.is_dimmed = false;
       
   356 
       
   357 		$("#WidgetArea")[0].className = '';
       
   358 
       
   359 		NOKIA.menu.softkeys_visibility = true;
       
   360 		NOKIA.menu.showSoftKeys();
       
   361 
       
   362 	});
       
   363 
       
   364 	// MenuItems DIV events
       
   365 	$("#MenuItemsArea").mouseover(function() {
       
   366 		if (NOKIA.helper.intervalId)
       
   367 			clearInterval(NOKIA.helper.intervalId);
       
   368 
       
   369 		$("#MenuItemsArea").show();
       
   370 	});
       
   371 
       
   372 	$("#MenuItemsArea").mouseout(function() {
       
   373 		if (NOKIA.helper.intervalId)
       
   374 			clearInterval(NOKIA.helper.intervalId);
       
   375 
       
   376 		NOKIA.helper.intervalId = setTimeout(function() {
       
   377 			NOKIA.menu.cancel();
       
   378 		}, 500);
       
   379 	});
       
   380 
       
   381 	// Tabs
       
   382 	$('#tabs').tabs( {
       
   383 	// select : function(event, ui){
       
   384 	// switch (ui.index) {
       
   385 	// case 1:
       
   386 	// $("event-battery-info").show();
       
   387 	// break;
       
   388 	// case 2:
       
   389 	// $("event-messaging-info").show();
       
   390 	// break;
       
   391 	// case 3:
       
   392 	// $("event-memory-info").show();
       
   393 	// break;
       
   394 	// case 4:
       
   395 	// $("settings-view").show();
       
   396 	// break;
       
   397 	//					
       
   398 	// }}
       
   399 	});
       
   400 	$(".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *").removeClass(
       
   401 			"ui-corner-all ui-corner-top").addClass("ui-corner-bottom");
       
   402 
       
   403 	/*
       
   404 	 * Event triggering
       
   405 	 */
       
   406 
       
   407 	// for battery
       
   408 	$("#event-battery").click(function(event) {
       
   409 		if (event.target.className == 'active') {
       
   410 			$("#event-icons").hide();
       
   411 			$("#event-battery-info").show();
       
   412 
       
   413 			/*
       
   414 			 * $('#slider').slider('option', 'value',
       
   415 			 * NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength());
       
   416 			 * NOKIA.emulator.child._BRIDGE_REF.helper.getBatteryStrength()
       
   417 			 * $('#slider').slider('option', 'value', 10);
       
   418 			 * $('#slider').slider();
       
   419 			 */
       
   420 		}
       
   421 	});
       
   422 
       
   423 	$("#event-battery-back").click(function(event) {
       
   424 		$("#event-icons").show();
       
   425 		$("#event-battery-info").hide();
       
   426 	});
       
   427 
       
   428 	// for messaging
       
   429 	$("#event-messaging").click(function(event) {
       
   430 		if (event.target.className == 'active') {
       
   431 			$("#event-icons").hide();
       
   432 			$("#event-messaging-info").show();
       
   433 		}
       
   434 	});
       
   435 
       
   436 	$("#event-messaging-back").click(function(event) {
       
   437 		$("#event-icons").show();
       
   438 		$("#event-messaging-info").hide();
       
   439 	});
       
   440 
       
   441 	// for memory
       
   442 	$("#event-memory").click(function(event) {
       
   443 		if (event.target.className == 'active') {
       
   444 			$("#event-icons").hide();
       
   445 			$("#event-memory-info").show();
       
   446 		}
       
   447 	});
       
   448 
       
   449 	$("#event-memory-back").click(function(event) {
       
   450 		$("#event-icons").show();
       
   451 		$("#event-memory-info").hide();
       
   452 	});
       
   453 
       
   454 	// for minView more info
       
   455 	$("#mini-view-back").click(function(event) {
       
   456 		$("#settings-view").show();
       
   457 		$("#mini-view-info").hide();
       
   458 	});
       
   459 
       
   460 	// Slider
       
   461 	$('#slider').slider(
       
   462 			{
       
   463 				min : 0,
       
   464 				max : 100,
       
   465 				step : 1,
       
   466 				value : 10,
       
   467 				animate : true,
       
   468 				slide : function(event, ui) {
       
   469 					$("#slider-value-panel > span").html(
       
   470 							ui.value.toString() + "%");
       
   471 				},
       
   472 				change : function(event, ui) {
       
   473 					var chargeValue = ui.value;
       
   474 					NOKIA.helper.trigger("power", "chargelevel", chargeValue);
       
   475 					if (NOKIA.version == 'WRT 1.1')
       
   476 						NOKIA.helper.triggerSapi("Service.SysInfo",
       
   477 								"Battery.BatteryStrength", {
       
   478 									Status : chargeValue
       
   479 								});
       
   480 				}
       
   481 			});
       
   482 	$("#slider-value-panel > span").html("10%");
       
   483 
       
   484 	var cc = $("#close-camera");
       
   485 	cc.click(NOKIA.helper.hideCamera);
       
   486 	// Bind Buttons to trigger values to WRT 1.0 / 1.1 bindings
       
   487 
       
   488 	$("#connect-charger").click(NOKIA.helper.triggerEvents);
       
   489 	$("#disconnect-charger").click(NOKIA.helper.triggerEvents);
       
   490 
       
   491 	$("#send-sms").click(NOKIA.helper.triggerEvents);
       
   492 	$("#send-mms").click(NOKIA.helper.triggerEvents);
       
   493 
       
   494 	$("#connect-memory-card").click(NOKIA.helper.triggerEvents);
       
   495 	$("#disconnect-memory-card").click(NOKIA.helper.triggerEvents);
       
   496 
       
   497 };
       
   498 
       
   499 EmulatorHelper.prototype.setHomeScreen = function() {
       
   500 	// HomeScreen Support
       
   501 	if (NOKIA.deviceList[NOKIA.currentDevice].homeScreenSupport) {
       
   502 
       
   503 		if (typeof NOKIA.emulator.plist.MiniViewEnabled != 'undefined') {
       
   504 			if (NOKIA.emulator.plist.MiniViewEnabled != 'false') {
       
   505 				$("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
       
   506 
       
   507 				// menu handlining
       
   508 				NOKIA.menu.softkeys_visibility = false;
       
   509 				NOKIA.menu.cancel();
       
   510 				NOKIA.menu.is_dimmed = true;
       
   511 
       
   512 				$("#loaderDiv").html("Click on widget for Return to Full view");
       
   513 				$("#loaderDiv")[0].className = 'green';
       
   514 				$("#loaderDiv").show();
       
   515 
       
   516 				$("#iframeMask").show();
       
   517 				$("#orientationIcon").show();
       
   518 
       
   519 				return true;
       
   520 			}
       
   521 		}
       
   522 	}
       
   523 	return false;
       
   524 };
       
   525 
       
   526 EmulatorHelper.prototype.getElementsLengthInObject = function(items) {
       
   527 	var count = 0;
       
   528 	for ( var i in items) {
       
   529 		if (!items[i].isDimmed)
       
   530 			count++;
       
   531 	}
       
   532 
       
   533 	return count;
       
   534 };
       
   535 
       
   536 EmulatorHelper.prototype.showCamera = function() {
       
   537 	$("#camera").show();
       
   538 	$("#WidgetArea").hide();
       
   539 };
       
   540 
       
   541 EmulatorHelper.prototype.hideCamera = function() {
       
   542 	$("#camera").hide();
       
   543 	$("#WidgetArea").show();
       
   544 };
       
   545 
       
   546 EmulatorHelper.prototype.triggerEvents = function(event) {
       
   547 	if (typeof event.target.id == 'undefined')
       
   548 		return false;
       
   549 
       
   550 	switch (event.target.id) {
       
   551 	// for battery
       
   552 	case 'connect-charger':
       
   553 		NOKIA.helper.trigger("power", "chargerconnected", 1);
       
   554 		if (NOKIA.version == 'WRT 1.1')
       
   555 			NOKIA.helper.triggerSapi("Service.SysInfo",
       
   556 					"Battery.ChargingStatus", {
       
   557 						Status : 1
       
   558 					});
       
   559 		break;
       
   560 
       
   561 	case 'disconnect-charger':
       
   562 		NOKIA.helper.trigger("power", "chargerconnected", 0);
       
   563 		if (NOKIA.version == 'WRT 1.1')
       
   564 			NOKIA.helper.triggerSapi("Service.SysInfo",
       
   565 					"Battery.ChargingStatus", {
       
   566 						Status : 0
       
   567 					});
       
   568 		break;
       
   569 
       
   570 	// for messaging
       
   571 	case 'send-sms':
       
   572 		if (NOKIA.version == 'WRT 1.1')
       
   573 			NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {
       
   574 				MessageType : 'SMS'
       
   575 			});
       
   576 		break;
       
   577 	case 'send-mms':
       
   578 		if (NOKIA.version == 'WRT 1.1')
       
   579 			NOKIA.helper.triggerSapi("Service.Messaging", "NewMessage", {
       
   580 				MessageType : 'MMS'
       
   581 			});
       
   582 		break;
       
   583 
       
   584 	// for memory
       
   585 	case 'connect-memory-card':
       
   586 		if (NOKIA.version == 'WRT 1.1')
       
   587 			NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {
       
   588 				Status : 1
       
   589 			});
       
   590 		break;
       
   591 	case 'disconnect-memory-card':
       
   592 		if (NOKIA.version == 'WRT 1.1')
       
   593 			NOKIA.helper.triggerSapi("Service.SysInfo", "Memory.MemoryCard", {
       
   594 				Status : 0
       
   595 			});
       
   596 		break;
       
   597 	}
       
   598 };
       
   599 
       
   600 EmulatorHelper.prototype.triggerSapi = function(provider, eventType, data) {
       
   601 	NOKIA.emulator.child.device.implementation.triggerListener(provider,
       
   602 			eventType, data);
       
   603 };
       
   604 
       
   605 EmulatorHelper.prototype.trigger = function(provider, eventType, data) {
       
   606 	NOKIA.emulator.child.widget.triggerListener(provider, eventType, data);
       
   607 };
       
   608 
       
   609 EmulatorHelper.prototype.showMiniviewHelp = function() {
       
   610 	$("#settings-view").hide();
       
   611 	$("#mini-view-info").show();
       
   612 };
       
   613 
       
   614 EmulatorHelper.prototype.checkDependencies = function() {
       
   615 
       
   616 	for ( var key in NOKIA.scriptsLoaded) {
       
   617 		if (!NOKIA.scriptsLoaded[key])
       
   618 			return false;
       
   619 	}
       
   620 
       
   621 	// for LSK
       
   622 	NOKIA.menu.setLsk(NOKIA.emulator.child.menu.show);
       
   623 
       
   624 	// for RSK
       
   625 	NOKIA.menu.setRsk(NOKIA.menu.exit);
       
   626 
       
   627 	return true;
       
   628 };
       
   629 
       
   630 function accelerationCallback(x, y, z) {
       
   631 	NOKIA.emulator.accelerationChanged(x, y, z);
       
   632 }