org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-11D59F76-EC4C-4297-B262-D5174E826B43.html
changeset 229 716254ccbcc0
equal deleted inserted replaced
228:913c9751c067 229:716254ccbcc0
       
     1 
       
     2 <!DOCTYPE html
       
     3   PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
       
     4 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="copyright" content="(C) Copyright 2009"/><meta name="DC.rights.owner" content="(C) Copyright 2009"/><meta name="DC.Type" content="mobileconcept"/><meta name="DC.Title" content="Landmarks Service API example"/><meta name="DC.Relation" scheme="URI" content="GUID-4ECCCBED-DE6D-4366-B037-90E874C4DF5C"/><meta name="DC.Relation" scheme="URI" content="GUID-7C69DDA4-16F1-4A8F-BDB2-4CB0015B4E81"/><meta name="DC.Relation" scheme="URI" content="GUID-65AAF569-D347-462B-B59A-9D7CA184AB9C"/><meta name="DC.Relation" scheme="URI" content="GUID-B8845FF1-D7F6-476A-8651-8B9C12D8789F"/><meta name="DC.Format" content="XHTML"/><meta name="DC.Identifier" content="GUID-11D59F76-EC4C-4297-B262-D5174E826B43"/><title>Landmarks Service API example </title><script type="text/javascript">
       
     5       function initPage() {}
       
     6     </script><link href="../PRODUCT_PLUGIN/book.css" rel="stylesheet" type="text/css"/><link href="css/s60/style.css" rel="stylesheet" type="text/css" media="all"/></head><body onload="initPage();"><div class="body"><div class="contentLeft prTxt"><h1 class="pageHeading" id="GUID-11D59F76-EC4C-4297-B262-D5174E826B43">Landmarks Service API example</h1><div>
       
     7 <p/>
       
     8 <p>This section presents the full source code of a working sample widget
       
     9 for the <a href="GUID-D581028C-06ED-422D-866E-AE6C93075084.html#GUID-D581028C-06ED-422D-866E-AE6C93075084">Landmarks Service</a>.
       
    10 You can download the <code>wgz</code> package for this widget from
       
    11 section <a href="GUID-775005BC-2FF8-45A9-BBA6-6CED6B5780A2.html#GUID-775005BC-2FF8-45A9-BBA6-6CED6B5780A2">Example widgets</a>.</p>
       
    12 <p>For general information about creating widgets, see section <a href="GUID-0E3095DB-03FF-4240-83F2-6D876AD2083A.html#GUID-0E3095DB-03FF-4240-83F2-6D876AD2083A">Widget component files</a>.</p>
       
    13 <div><h3>Info.plist</h3>
       
    14 <pre class="codeblock" id="GUID-0099622C-7424-4D2C-95E5-759BB81D32E8">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
       
    15 &lt;!DOCTYPE plist PUBLIC "-//Nokia//DTD PLIST 1.0//EN" "http://www.nokia.com/NOKIA_COM_1/DTDs/plist-1.0.dtd"&gt;
       
    16 &lt;plist version="1.0"&gt;
       
    17 &lt;dict&gt;
       
    18     &lt;key&gt;DisplayName&lt;/key&gt;
       
    19     &lt;string&gt;LandmarksSample&lt;/string&gt;
       
    20     &lt;key&gt;Identifier&lt;/key&gt;
       
    21     &lt;string&gt;com.nokia.widget.sapi.landmarks.sample&lt;/string&gt;
       
    22     &lt;key&gt;Version&lt;/key&gt;
       
    23     &lt;string&gt;1.0&lt;/string&gt;
       
    24     &lt;key&gt;MainHTML&lt;/key&gt;
       
    25     &lt;string&gt;landmarks-sample.html&lt;/string&gt;
       
    26 &lt;/dict&gt;
       
    27 &lt;/plist&gt;</pre>
       
    28 </div>
       
    29 <div><h3>landmarks-sample.html</h3>
       
    30 <pre class="codeblock" id="GUID-31B02315-A86A-4061-822B-7F3C4F96133C">&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
       
    31 &lt;html&gt;
       
    32 &lt;head&gt;
       
    33     &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
       
    34     &lt;script type="text/javascript" src="js/landmarks-sample.js" charset="utf-8"&gt;&lt;/script&gt;
       
    35     &lt;script type="text/javascript" src="js/common.js" charset="utf-8"&gt;&lt;/script&gt;
       
    36 &lt;/head&gt;
       
    37 &lt;body onload='setup()' bgcolor="#ddeeff"&gt;
       
    38     &lt;form&gt;
       
    39         &lt;h3&gt;Landmarks Service API Sample Widget&lt;/h3&gt;
       
    40         &lt;input type="button" onclick="addCategory('img1');" value="AddCategory"&gt;&lt;img id="img1" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    41         &lt;input type="button" onclick="addLandmark('img2')" value="AddLandmark"&gt;&lt;img id="img2" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    42         &lt;input type="button" onclick="getListDatabases('img3')" value="GetListDatabases"&gt;&lt;img id="img3" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    43         &lt;input type="button" onclick="getListCategories('img4')" value="GetListCategoriesSync"&gt;&lt;img id="img4" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    44         &lt;input type="button" onclick="getListCategoriesAsync('img5')" value="GetListCategoriesAsync"&gt;&lt;img id="img5" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    45         &lt;input type="button" onclick="getListLandmarks('img6')" value="GetListLandmarksSync"&gt;&lt;img id="img6" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    46         &lt;input type="button" onclick="getListLandmarksAsync('img7')" value="GetListLandmarksAsync"&gt;&lt;img id="img7" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    47         &lt;input type="button" onclick="cancelCategoriesAsync('img8')" value="CancelCategoriesAsync"&gt;&lt;img id="img8" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    48         &lt;input type="button" onclick="cancelLandmarksAsync('img9')" value="CancelLandmarksAsync"&gt;&lt;img id="img9" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    49         &lt;input type="button" onclick="deleteCategory('img10')" value="DeleteCategory"&gt;&lt;img id="img10" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    50         &lt;input type="button" onclick="deleteLandmark('img11')" value="DeleteLandMark"&gt;&lt;img id="img11" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    51         &lt;input type="button" onclick="exportLandmarks('img12')" value="ExportLandmarks"&gt;&lt;img id="img12" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    52         &lt;input type="button" onclick="importLandmarks('img13')" value="ImportLandmarks"&gt;&lt;img id="img13" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;br&gt;
       
    53         &lt;input type="button" onclick="organiseLandmarks('img14')" value="OrganiseLandmarks"&gt;&lt;img id="img14" src="pic/blank.png" width="25" height="25" align="center"&gt;&lt;hr&gt;
       
    54         &lt;div class='landmarks' id='landmarks' bgcolor="#ddeeff" style=width:100%;height:100%;overflow:auto&gt;
       
    55         &lt;/div&gt;
       
    56     &lt;/form&gt;
       
    57 &lt;/body&gt;
       
    58 &lt;/html&gt;
       
    59 </pre>
       
    60 </div>
       
    61 <div><h3>common.js</h3>
       
    62 <pre class="codeblock" id="GUID-A5CDC8EA-E226-45B8-8B09-4DA079530315">// common.js
       
    63 //
       
    64 // This file contains some utility functions
       
    65 
       
    66 // Check the error code and show the information to users
       
    67 function checkError(message, resultList, divId, imgId)
       
    68 {
       
    69   var errCode = resultList.ErrorCode;
       
    70   var msg = "";
       
    71 
       
    72   if (errCode) {
       
    73     msg = message + "&lt;BR&gt;" + "Failed Error: " + errCode + "&lt;BR&gt;";
       
    74     if(resultList.ErrorMessage != undefined)
       
    75       msg += "Error Message: " + resultList.ErrorMessage;
       
    76     showIMG(imgId,"no");
       
    77   } else {
       
    78     showIMG(imgId,"yes");
       
    79   }
       
    80 
       
    81   //print error message
       
    82   if(divId != null &amp;&amp; divId != undefined)
       
    83     document.getElementById(divId).innerHTML = msg;
       
    84   console.info(msg);
       
    85 
       
    86   return errCode;
       
    87 }
       
    88 
       
    89 // Build the message by reading a iteratorable list in a recursive manner
       
    90 function showIterableList(iterator)
       
    91 {
       
    92   var msg = "";
       
    93   try
       
    94   {
       
    95     iterator.reset();
       
    96     var item;
       
    97     while (( item = iterator.getNext()) != undefined ){
       
    98       msg += showObject( item );
       
    99     }
       
   100   }
       
   101   catch(e)
       
   102   {
       
   103     alert('&lt;showIterableList&gt; ' + e);
       
   104   }
       
   105   return msg;
       
   106 }
       
   107 
       
   108 // Build the message by reading a JS object in a recursive manner
       
   109 function showObject( obj )
       
   110 {
       
   111   var txt = "";
       
   112   try {
       
   113     if ( typeof obj != 'object' )
       
   114       return "" + obj + '&lt;BR/&gt;';
       
   115     else {
       
   116       for(var key in obj) {
       
   117         txt +=  key + ":";
       
   118         txt += showObject( obj[key] );
       
   119         txt += '&lt;BR/&gt;';
       
   120       }
       
   121       txt += '&lt;BR/&gt;';
       
   122     }
       
   123   }
       
   124   catch (e)
       
   125   {
       
   126     alert("showObject: " + e);
       
   127   }
       
   128   return txt;
       
   129 }
       
   130 
       
   131 // Show the image to indicate the test result
       
   132 function showIMG(imgId, isOK)
       
   133 {
       
   134   if(imgId == null || imgId == undefined)
       
   135     return;
       
   136 
       
   137   if(isOK == "yes")
       
   138     document.getElementById(imgId).src = "pic/yes.png";
       
   139   else if(isOK == "no")
       
   140     document.getElementById(imgId).src = "pic/no.png";
       
   141   else
       
   142     document.getElementById(imgId).src = "pic/blank.png";
       
   143 }
       
   144 
       
   145 // Show elements in object by using 'alert'
       
   146 function testObject(obj)
       
   147 {
       
   148   var msg = "";
       
   149   for(var key in obj) {
       
   150     msg = msg + ":" + key + "=" + obj[key];
       
   151   }
       
   152   alert(msg);
       
   153 }
       
   154 
       
   155 // Test whether the input is numeric
       
   156 function IsNumeric(sText)
       
   157 {
       
   158   var ValidChars = "0123456789.";
       
   159   var IsNumber=true;
       
   160   var Char;
       
   161 
       
   162   for (i = 0; i &lt; sText.length &amp;&amp; IsNumber == true; i++)
       
   163   {
       
   164     Char = sText.charAt(i);
       
   165     if (ValidChars.indexOf(Char) == -1)
       
   166     {
       
   167       IsNumber = false;
       
   168     }
       
   169   }
       
   170   return IsNumber;
       
   171 }</pre>
       
   172 </div>
       
   173 <div><h3>landmarks-sample.js</h3>
       
   174 <pre class="codeblock" id="GUID-628E92C0-DDF4-440E-9F6B-7593E8CCC1B5">// landmarks-sample.js
       
   175 //
       
   176 // In this sample Categories will be added, deleted, and listed from default database,
       
   177 // Landmarks will be imported, exported, added, deleted, and listed from sample database
       
   178 // Also, async operation will be canceled
       
   179 
       
   180 //SAPI Error Codes
       
   181 // 0    - Success
       
   182 // 1000 - InvalidServiceArgument
       
   183 // 1001 - UnknownArgumentName
       
   184 // 1002 - BadArgumentType
       
   185 // 1003 - MissingArgument
       
   186 // 1004 - ServiceNotSupported
       
   187 // 1005 - ServiceInUse
       
   188 // 1006 - ServiceNotReady
       
   189 // 1007 - NoMemory
       
   190 // 1008 - HardwareNotAvailable
       
   191 // 1009 - ServerBusy
       
   192 // 1010 - EntryExists
       
   193 // 1011 - AccessDenied
       
   194 // 1012 - NotFound
       
   195 // 1013 - UnknownFormat
       
   196 // 1014 - GeneralError
       
   197 // 1015 - CancelSuccess
       
   198 // 1016 - ServiceTimedOut
       
   199 // 1017 - PathNotFound
       
   200 
       
   201 
       
   202 // Declare the service object
       
   203 var so;
       
   204 
       
   205 // id of the div used to display information
       
   206 const DIV_ID = 'landmarks';
       
   207 
       
   208 // imgid for callback1 function
       
   209 var imgid_callback1;
       
   210 
       
   211 // imgid for callback2 function
       
   212 var imgid_callback2;
       
   213 
       
   214 // Called from onload()
       
   215 function setup()
       
   216 {
       
   217   try
       
   218   {
       
   219     so = device.getServiceObject("Service.Landmarks", "IDataSource");
       
   220     console.info("setup: so: %s", so);
       
   221   }
       
   222   catch(e)
       
   223   {
       
   224     alert('&lt;setup&gt; ' +e);
       
   225   }
       
   226 }
       
   227 
       
   228 // Add new Category
       
   229 // Note: Category with the CategoryName can not be added twice.
       
   230 // So, you should delete just added category first and add category after that
       
   231 function addCategory(imgId)
       
   232 {
       
   233   // Setup input params using dot syntax
       
   234   var category = new Object();
       
   235   category.CategoryName = 'MyCategory';
       
   236   var criteria = new Object();
       
   237   criteria.Type = 'Category';
       
   238   criteria.Data = category;
       
   239   try
       
   240   {
       
   241     var resultList = so.IDataSource.Add(criteria);
       
   242     checkError("IDataSource::addCategory",resultList,DIV_ID,imgId);
       
   243   }
       
   244   catch(e)
       
   245   {
       
   246     showIMG(imgId,"no");
       
   247     alert ("addCategory: " + e);
       
   248   }
       
   249 }
       
   250 
       
   251 // Populate a Landmark Object with sample data
       
   252 function populateLandmark(landmark)
       
   253 {
       
   254   var landmarkfields = new Object();
       
   255   landmarkfields.Country = 'USA';
       
   256   landmarkfields.AreaCode = '01803';
       
   257   landmarkfields.City = 'Boston';
       
   258   landmarkfields.District = 'Dist';
       
   259   landmarkfields.Street = 'Wayside Rd';
       
   260   landmarkfields.Telephone = '781-993-9393';
       
   261 
       
   262   landmark.DatabaseURI      = 'file://c:eposlm.ldb';
       
   263   landmark.LandmarkName     = 'NewLandmark';
       
   264   landmark.LandmarkDesc     = 'My Landmark';
       
   265   landmark.LandmarkFields   = landmarkfields;
       
   266 }
       
   267 
       
   268 // Add new Landmark (sync operation)
       
   269 function addLandmark(imgId)
       
   270 {
       
   271   // Setup input params using dot syntax
       
   272   var criteria = new Object();
       
   273   criteria.Type = 'Landmark';
       
   274 
       
   275   try
       
   276   {
       
   277     var lm = so.IDataSource.New( criteria );
       
   278     populateLandmark(lm);
       
   279     var criteria1 = new Object();
       
   280     criteria1.Type = 'Landmark';
       
   281     criteria1.Data = lm;
       
   282     var resultList = so.IDataSource.Add(criteria1);
       
   283     checkError("IDataSource::addLandmark",resultList,DIV_ID,imgId);
       
   284   }
       
   285   catch(e)
       
   286   {
       
   287     showIMG(imgId,"no");
       
   288     alert ("addLandmark: " + e);
       
   289   }
       
   290 }
       
   291 
       
   292 
       
   293 // Get List of all Databases (sync operation)
       
   294 function getListDatabases(imgId)
       
   295 {
       
   296   // Setup input params using dot syntax
       
   297   var criteria = new Object();
       
   298   criteria.Type = 'Database';
       
   299   try
       
   300   {
       
   301     var resultList = so.IDataSource.GetList(criteria);
       
   302     if(!checkError("IDataSource::getListDatabases",resultList,DIV_ID,imgId)) {
       
   303       document.getElementById(DIV_ID).innerHTML = showIterableList(resultList.ReturnValue);
       
   304     }
       
   305   }
       
   306   catch(e)
       
   307   {
       
   308     showIMG(imgId,"no");
       
   309     alert ("getListDatabases: " + e);
       
   310   }
       
   311 }
       
   312 
       
   313 // Get List of all Categories (sync operation)
       
   314 function getListCategories(imgId)
       
   315 {
       
   316   // Setup input params using dot syntax
       
   317   var criteria = new Object();
       
   318   criteria.Type = 'Category';
       
   319   try
       
   320   {
       
   321     var resultList = so.IDataSource.GetList(criteria);
       
   322     if(!checkError("IDataSource::getListCategories",resultList,DIV_ID,imgId)) {
       
   323       document.getElementById(DIV_ID).innerHTML = showIterableList(resultList.ReturnValue);
       
   324     }
       
   325   }
       
   326   catch(e)
       
   327   {
       
   328     showIMG(imgId,"no");
       
   329     alert ("getListCategories: " + e);
       
   330   }
       
   331 }
       
   332 
       
   333 // Get List of all Categories (Async operation)
       
   334 function getListCategoriesAsync(imgId)
       
   335 {
       
   336   // Setup input params using dot syntax
       
   337   var criteria = new Object();
       
   338   criteria.Type = 'Category';
       
   339   try
       
   340   {
       
   341     imgid_callback1 = imgId;
       
   342     var resultList = so.IDataSource.GetList(criteria, callback1);
       
   343     if(!checkError("IDataSource::getListCategoriesAsync",resultList,DIV_ID,imgId))
       
   344       showIMG(imgId, "");
       
   345   }
       
   346   catch(e)
       
   347   {
       
   348     showIMG(imgId,"no");
       
   349     alert ("addCategory: " + e);
       
   350   }
       
   351 }
       
   352 
       
   353 // Get List of Landmarks (sync operation)
       
   354 function getListLandmarks(imgId)
       
   355 {
       
   356   var sort = new Object();
       
   357   sort.Key = 'LandmarkName';
       
   358   sort.Order = 'Descending';
       
   359   var criteria = new Object();
       
   360   criteria.Type = 'Landmark';
       
   361   criteria.Sort = sort;
       
   362   try
       
   363   {
       
   364     var resultList = so.IDataSource.GetList(criteria);
       
   365     if(!checkError("IDataSource::getListLandmarks",resultList,DIV_ID,imgId)) {
       
   366       document.getElementById(DIV_ID).innerHTML = showIterableList(resultList.ReturnValue);
       
   367     }
       
   368   }
       
   369   catch(e)
       
   370   {
       
   371     showIMG(imgId,"no");
       
   372     alert ("getListLandmarks: " + e);
       
   373   }
       
   374 }
       
   375 
       
   376 // Get List of Landmarks (Async operation)
       
   377 function getListLandmarksAsync(imgId)
       
   378 {
       
   379   var sort = new Object();
       
   380   sort.Key = 'LandmarkName';
       
   381   sort.Order = 'Descending';
       
   382   var criteria = new Object();
       
   383   criteria.Type = 'Landmark';
       
   384   criteria.Sort = sort;
       
   385   try
       
   386   {
       
   387     imgid_callback2 = imgId;
       
   388     var resultList = so.IDataSource.GetList(criteria, callback2);
       
   389     if(!checkError("IDataSource::getListLandmarksAsync",resultList,DIV_ID,imgId))
       
   390       showIMG(imgId, "");
       
   391   }
       
   392   catch(e)
       
   393   {
       
   394     showIMG(imgId,"no");
       
   395     alert ("getListLandmarksAsync: " + e);
       
   396   }
       
   397 }
       
   398 
       
   399 // cancel get categories
       
   400 function cancelCategoriesAsync(imgId)
       
   401 {
       
   402   // Setup input params using dot syntax
       
   403   var criteria = new Object();
       
   404   criteria.Type = 'Category';
       
   405   try
       
   406   {
       
   407     imgid_callback1 = imgId;
       
   408     var resultList = so.IDataSource.GetList(criteria, callback1);
       
   409     if(!checkError("IDataSource::cancelCategoriesAsync",resultList,DIV_ID,imgId)) {
       
   410       showIMG(imgId, "");
       
   411       var criteria2 = new Object();
       
   412       criteria2.TransactionID = resultList.TransactionID;
       
   413       var resultList2 = so.IDataSource.Cancel(criteria2);
       
   414       checkError("IDataSource::cancelCategoriesAsync",resultList2,DIV_ID,imgId);
       
   415     }
       
   416   }
       
   417   catch(e)
       
   418   {
       
   419     showIMG(imgId,"no");
       
   420     alert ("cancelCategoriesAsync: " + e);
       
   421   }
       
   422 }
       
   423 
       
   424 // cancel get landmarks
       
   425 function cancelLandmarksAsync(imgId)
       
   426 {
       
   427   var sort = new Object();
       
   428   sort.Key = 'LandmarkName';
       
   429   sort.Order = 'Descending';
       
   430   var criteria = new Object();
       
   431   criteria.Type = 'Landmark';
       
   432   criteria.Sort = sort;
       
   433   try
       
   434   {
       
   435     imgid_callback2 = imgId;
       
   436     var resultList = so.IDataSource.GetList(criteria, callback2);
       
   437     if(!checkError("IDataSource::cancelLandmarksAsync",resultList,DIV_ID,imgId)) {
       
   438       showIMG(imgId, "");
       
   439       var criteria2 = new Object();
       
   440       criteria2.TransactionID = resultList.TransactionID;
       
   441       var resultList2 = so.IDataSource.Cancel(criteria2);
       
   442       checkError("IDataSource::cancelLandmarksAsync",resultList2,DIV_ID,imgId);
       
   443     }
       
   444   }
       
   445   catch(e)
       
   446   {
       
   447     showIMG(imgId,"no");
       
   448     alert ("cancelLandmarksAsync: " + e);
       
   449   }
       
   450 }
       
   451 
       
   452 // Delete one Category (sync operation)
       
   453 function deleteCategory(imgId)
       
   454 {
       
   455   var landmarkIdStr = prompt("Please type the landmark id", "0");
       
   456   if(landmarkIdStr == "" || landmarkIdStr == null)
       
   457     return;
       
   458 
       
   459   // Setup input params using dot syntax
       
   460   var data = new Object();
       
   461   data.id = parseInt(landmarkIdStr);
       
   462   var criteria = new Object();
       
   463   criteria.Type = 'Category';
       
   464   criteria.Data = data;
       
   465   try
       
   466   {
       
   467     var resultList = so.IDataSource.Delete(criteria);
       
   468     checkError("IDataSource::deleteCategory",resultList,DIV_ID,imgId);
       
   469   }
       
   470   catch(e)
       
   471   {
       
   472     showIMG(imgId,"no");
       
   473     alert ("deleteCategory: " + e);
       
   474   }
       
   475 }
       
   476 
       
   477 // Delete one Landmark (sync operation)
       
   478 function deleteLandmark(imgId)
       
   479 {
       
   480   var landmarkIdStr = prompt("Please type the landmark id", "0");
       
   481   if(landmarkIdStr == "" || landmarkIdStr == null)
       
   482     return;
       
   483 
       
   484   // Setup input params using dot syntax
       
   485   var data = new Object();
       
   486   data.id = parseInt(landmarkIdStr);
       
   487   var criteria = new Object();
       
   488   criteria.Type = 'Landmark';
       
   489   criteria.Data = data;
       
   490   try
       
   491   {
       
   492     var resultList = so.IDataSource.Delete(criteria);
       
   493     checkError("IDataSource::deleteLandmark",resultList,DIV_ID,imgId);
       
   494   }
       
   495   catch(e)
       
   496   {
       
   497     showIMG(imgId,"no");
       
   498     alert ("deleteLandmark: " + e);
       
   499   }
       
   500 }
       
   501 
       
   502 // Export specific Landmarks to xml file (sync operation)
       
   503 // When we export file already exist it returns an errorCode !!!
       
   504 function exportLandmarks(imgId)
       
   505 {
       
   506   // Setup input params using dot syntax
       
   507   var data = new Object();
       
   508   data.DestinationFile = 'landmarks-export.xml';
       
   509   data.MimeType = 'application/vnd.nokia.landmarkcollection+xml';
       
   510   data.IdList = [ "3", "4" ];
       
   511   var criteria = new Object();
       
   512   criteria.Type = 'Landmark';
       
   513   criteria.Data = data;
       
   514   try
       
   515   {
       
   516     var resultList = so.IDataSource.Export(criteria);
       
   517     checkError("IDataSource::exportLandmarks",resultList,DIV_ID,imgId);
       
   518   }
       
   519   catch(e)
       
   520   {
       
   521     showIMG(imgId,"no");
       
   522     alert ("exportLandmarks: " + e);
       
   523   }
       
   524 }
       
   525 
       
   526 // Import Landmarks from xml file (sync operation)
       
   527 function importLandmarks(imgId)
       
   528 {
       
   529   // Setup input params using dot syntax
       
   530   var data = new Object();
       
   531   data.SourceFile = 'landmarks-export.xml';
       
   532   data.MimeType = 'application/vnd.nokia.landmarkcollection+xml';
       
   533   var criteria = new Object();
       
   534   criteria.Type = 'Landmark';
       
   535   criteria.Data = data;
       
   536   try
       
   537   {
       
   538     var resultList = so.IDataSource.Import(criteria);
       
   539     checkError("IDataSource::importLandmarks",resultList,DIV_ID,imgId);
       
   540   }
       
   541   catch(e)
       
   542   {
       
   543     showIMG(imgId,"no");
       
   544     alert ("importLandmarks: " + e);
       
   545   }
       
   546 }
       
   547 
       
   548 // Organise Landmarks with entered ladmark id (sync operation)
       
   549 function organiseLandmarks(imgId)
       
   550 {
       
   551   // Setup input params using dot syntax
       
   552   var landmarkIdStr = prompt("Please type the landmark id", "0");
       
   553   if(landmarkIdStr == "" || landmarkIdStr == null)
       
   554     return;
       
   555 
       
   556   var data = new Object();
       
   557   data.id = parseInt(landmarkIdStr);
       
   558   data.IdList = [ "3", "4" ];
       
   559   var criteria = new Object();
       
   560   criteria.Type = 'Landmark';
       
   561   criteria.Data = data;
       
   562   criteria.OperationType = 'Associate';
       
   563   try
       
   564   {
       
   565     var resultList = so.IDataSource.Organise(criteria);
       
   566     checkError("IDataSource::organiseLandmarks",resultList,DIV_ID,imgId);
       
   567   }
       
   568   catch(e)
       
   569   {
       
   570     showIMG(imgId,"no");
       
   571     alert ("organiseLandmarks: " + e);
       
   572   }
       
   573 }
       
   574 
       
   575 // This is the asynchronous callback handler
       
   576 function callback1(transId, eventCode, result)
       
   577 {
       
   578   console.info("callback1: transId: %d  eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode);
       
   579   if(!checkError("IDataSource::getListCategoriesAsync",result,DIV_ID,imgid_callback1)) {
       
   580     document.getElementById(DIV_ID).innerHTML = showIterableList(result.ReturnValue);
       
   581   }
       
   582 }
       
   583 
       
   584 // This is the asynchronous callback handler
       
   585 function callback2(transId, eventCode, result)
       
   586 {
       
   587   console.info("callback2: transId: %d  eventCode: %d result.ErrorCode: %d", transId, eventCode, result.ErrorCode);
       
   588   if(!checkError("IDataSource::getListLandmarksAsync",result,DIV_ID,imgid_callback2)) {
       
   589     document.getElementById(DIV_ID).innerHTML = showIterableList(result.ReturnValue);
       
   590   }
       
   591 }</pre>
       
   592 </div>
       
   593 </div></div></div><div class="footer"><hr/><div class="copy">© Nokia 2009.</div></div></body></html>