[gnome-maps/wip/routing2: 2/11] Add abstract RouteService class



commit d9f1406a0ba86ddb1f0434f55ae48db2ff57cfad
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Fri Aug 23 06:15:55 2013 +0200

    Add abstract RouteService class
    
    The RouteService class is meant as a base class for
    route service classes.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728695

 src/gnome-maps.js.gresource.xml |    1 +
 src/routeService.js             |   57 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index 5fbdbda..1770331 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -14,6 +14,7 @@
     <file>path.js</file>
     <file>placeStore.js</file>
     <file>route.js</file>
+    <file>routeService.js</file>
     <file>searchPopup.js</file>
     <file>settings.js</file>
     <file>sidebar.js</file>
diff --git a/src/routeService.js b/src/routeService.js
new file mode 100644
index 0000000..89221f9
--- /dev/null
+++ b/src/routeService.js
@@ -0,0 +1,57 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * Copyright (c) 2013 Mattias Bengtsson.
+ *
+ * GNOME Maps is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * GNOME Maps is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
+ */
+
+const Soup = imports.gi.Soup;
+
+const Lang = imports.lang;
+
+const Route = imports.route;
+const EPAF = imports.epaf;
+const HTTP = imports.http;
+
+const RouteService = new Lang.Class({
+    Name: 'RouteService',
+    Abstract: true,
+
+    _init: function() {
+        this._session = new Soup.SessionAsync({ user_agent : "gnome-maps" });
+    },
+
+    _buildURL: function(viaPoints, transportation) {},
+
+    _parseResult: function(result) {},
+
+    _transportationToString: function() {},
+
+    getRoute: function(viaPoints, transportationType, callback) {
+        let url = this._buildURL(viaPoints, transportationType),
+            msg = Soup.Message.new('GET', url);
+        this._session.queue_message(msg, (function(session, message) {
+            if (message.status_code === 200) {
+                let result = message.response_body.data;
+                callback(undefined, this._parseResult(result));
+            } else {
+                callback("Error: " + message.status_code);
+            }
+        }).bind(this));
+    }
+});


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]