[Xfce4-commits] <postler:master> Support mid: URIs to open individual messages

Christian Dywan noreply at xfce.org
Mon Jul 25 00:10:01 CEST 2011


Updating branch refs/heads/master
         to ff0a84d1ab9e74e2c577fbff966e2fcb3749c140 (commit)
       from 5e93d680fad5ea767cbc19d4424daca740efae21 (commit)

commit ff0a84d1ab9e74e2c577fbff966e2fcb3749c140
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Jul 24 23:09:16 2011 +0200

    Support mid: URIs to open individual messages
    
    No support for individual attachments for now.

 postler/postler-reader.vala |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/postler/postler-reader.vala b/postler/postler-reader.vala
index 05f9bb2..5e4c56e 100644
--- a/postler/postler-reader.vala
+++ b/postler/postler-reader.vala
@@ -34,8 +34,12 @@ public class Postler.Reader {
         var context = new GLib.OptionContext (
             /* i18n: The meaning of the uppercase values is analogous to the
                      fields at the top of a message, ie. From, To, Copy */
-            _("[mailto:][ADDRESS][?subject=SUBJECT][&body=BODY]")
-          + _("[&from=FROM][&to=TO][&cc=COPY][&attach=ATTACHMENT][&part=PART]"));
+            _("[mailto:][ADDRESS][?subject=SUBJECT][&body=BODY]") + "\n\t"
+          + _("[&from=FROM][&to=TO][&cc=COPY][&attach=ATTACHMENT][&in-reply-to=MESSAGE_ID]")
+          + "\n  %s ".printf (Config.PACKAGE_NAME)
+          + _("[file://][FILENAME]")
+          + "\n  %s ".printf (Config.PACKAGE_NAME)
+          + _("mid:[MESSAGE_ID][/ATTACHMENT_ID]"));
         context.set_help_enabled (true);
         context.add_main_entries (options, null);
         context.add_group (Gtk.get_option_group (false));
@@ -101,12 +105,15 @@ public class Postler.Reader {
 
         /* mailto, ? or @ implies compose, otherwise file implies content */
         if (module == null && filenames != null && filenames[0] != null) {
-            if (filenames[0].has_prefix ("mailto:")
+            if (filenames[0].has_prefix ("file://")
+             || filenames[0].has_prefix ("mid:"))
+                module = "content";
+            else if (filenames[0].has_prefix ("mailto:")
              || filenames[0].has_prefix ("?")
              || (filenames[0].chr (-1, '@') != null && filenames[0].chr (-1, '/') == null))
                 module = "compose";
             else
-                module = "content";
+                GLib.error (_("Invalid argument passed: %s"), filenames[0]);
         }
 
         if (module == null)
@@ -152,6 +159,13 @@ public class Postler.Reader {
                             message = new Message.from_file (GLib.File.new_for_uri (filename));
                         else if (FileUtils.test (filename, FileTest.EXISTS))
                             message = new Message.from_file (GLib.File.new_for_path (filename));
+                        else if (filename.has_prefix ("mid:") && filename.chr (-1, '/') != null) {
+                            string[] pieces = filename.substring (4, -1).split ("/");
+                            GLib.warning (_("Opening attachments is not currently supported"));
+                            message = new Message.from_id (pieces[0]);
+                        }
+                        else if (filename.has_prefix ("mid:"))
+                            message = new Message.from_id (filename.substring (4, -1));
                         else
                             message = new Message.from_id (filename);
                     } catch (GLib.Error error) {


More information about the Xfce4-commits mailing list