summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2018-08-15 15:06:07 +0200
committermvglasow <michael -at- vonglasow.com>2018-08-15 15:06:07 +0200
commit722e41fb0a5e0c56ca9657291c183464b693b0b7 (patch)
treef1dcf4e5b36d95c97352125e96ecd3787c29781f
parent25796616d6afd072a614abc953ed0c5914f450ab (diff)
downloadnavit-722e41fb0a5e0c56ca9657291c183464b693b0b7.tar.gz
Add:traffic:API function to retrieve message store
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r--navit/traffic.c14
-rw-r--r--navit/traffic.h14
2 files changed, 28 insertions, 0 deletions
diff --git a/navit/traffic.c b/navit/traffic.c
index cd32731a5..618d18c23 100644
--- a/navit/traffic.c
+++ b/navit/traffic.c
@@ -4846,6 +4846,20 @@ struct traffic_message ** traffic_get_messages_from_xml_string(struct traffic *
return ret;
}
+struct traffic_message ** traffic_get_stored_messages(struct traffic *this_) {
+ struct traffic_message ** ret = g_new0(struct traffic_message *, g_list_length(this_->shared->messages) + 1);
+ struct traffic_message ** out = ret;
+ GList * in = this_->shared->messages;
+
+ while (in) {
+ *out = (struct traffic_message *) in->data;
+ in = g_list_next(in);
+ out++;
+ }
+
+ return ret;
+}
+
void traffic_process_messages(struct traffic * this_, struct traffic_message ** messages) {
struct traffic_message ** cur_msg;
diff --git a/navit/traffic.h b/navit/traffic.h
index bcc539826..5298b888e 100644
--- a/navit/traffic.h
+++ b/navit/traffic.h
@@ -924,6 +924,20 @@ struct traffic_message ** traffic_get_messages_from_xml_string(struct traffic *
struct map * traffic_get_map(struct traffic *this_);
/**
+ * @brief Returns currently active traffic messages.
+ *
+ * If multiple plugin instances are active, this will give the same result for any plugin, as traffic messages are
+ * shared between instances.
+ *
+ * @param this_ The traffic plugin instance
+ *
+ * @return A null-terminated array of traffic messages. The caller is responsible for freeing the array (not its
+ * elements) when it is no longer needed. This method will always return a valid pointer—if the message store is empty,
+ * an empty array (with just one single NULL element) will be returned.
+ */
+struct traffic_message ** traffic_get_stored_messages(struct traffic *this_);
+
+/**
* @brief Processes new traffic messages.
*
* Calling this method delivers new messages in a “push” manner (as opposed to the “pull” fashion of