[pan: 11/21] Added experimental support for sending Face header.




commit a5c8e4258f5b6fe96856ef1e80c297a552bbd732
Author: FoxMcCloud45 <foxmccloud45 hotmail com>
Date:   Wed Jul 7 01:15:59 2021 +0200

    Added experimental support for sending Face header.

 pan/data-impl/profiles.cc  |  2 ++
 pan/data/data.h            |  1 +
 pan/gui/post-ui.cc         | 17 +++++++++++++++++
 pan/gui/post-ui.h          |  2 +-
 pan/gui/profiles-dialog.cc | 10 +++++++++-
 pan/gui/profiles-dialog.h  |  1 +
 6 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/pan/data-impl/profiles.cc b/pan/data-impl/profiles.cc
index a6e6bb5..ad6a024 100644
--- a/pan/data-impl/profiles.cc
+++ b/pan/data-impl/profiles.cc
@@ -126,6 +126,7 @@ namespace
       else if (element_name == "gpg-signature") p.gpg_sig_uid.assign (t.str, t.len);
       else if (element_name == "attribution") p.attribution.assign (t.str, t.len);
       else if (element_name == "fqdn") p.fqdn.assign (t.str, t.len);
+      else if (element_name == "face") p.face.assign (t.str, t.len);
       else if (element_name == "xface") p.xface.assign (t.str, t.len);
       else if (element_name == "username") p.username.assign (t.str, t.len);
       else if (element_name == "address") p.address.assign (t.str, t.len);
@@ -209,6 +210,7 @@ ProfilesImpl :: serialize (std::ostream& out) const
     out << indent(depth) << "<username>" << escaped(it->second.username) << "</username>\n";
     out << indent(depth) << "<address>" << escaped(it->second.address) << "</address>\n";
     out << indent(depth) << "<server>" << escaped(it->second.posting_server.to_view()) << "</server>\n";
+    out << indent(depth) << "<face>" << escaped(it->second.face) << "</face>\n";
     out << indent(depth) << "<xface>" << escaped(it->second.xface) << "</xface>\n";
     if (!it->second.signature_file.empty() && it->second.sig_type != Profile::GPGSIG) {
       const char * type;
diff --git a/pan/data/data.h b/pan/data/data.h
index b6e180d..e54f223 100644
--- a/pan/data/data.h
+++ b/pan/data/data.h
@@ -109,6 +109,7 @@ namespace pan
     std::string signature_file;
     std::string attribution;
     std::string fqdn;
+    std::string face;
     std::string xface;
     Quark posting_server;
 
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index c983f21..2a081cc 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1658,6 +1658,23 @@ PostUI :: new_message_from_ui (Mode mode, bool copy_body)
     g_mime_object_set_header ((GMimeObject *) msg, "Reply-To", replyto.str);
 #endif
 
+  // headers from posting profile (via prefs): Face
+  if (!profile.face.empty())
+  {
+    std::string f;
+    f += profile.face;
+
+    for (int i = GMIME_FOLD_BASE64_INTERVAL; i < f.length(); i += GMIME_FOLD_BASE64_INTERVAL)
+    {
+      f.insert (i, " ");
+    }
+#ifdef HAVE_GMIME_30
+    g_mime_object_set_header ((GMimeObject *) msg, "Face", f.c_str(), NULL);
+#else
+    g_mime_object_set_header ((GMimeObject *) msg, "Face", f.c_str());
+#endif
+  }
+
   // headers from posting profile(via prefs): X-Face
   if (!profile.xface.empty())
   {
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 320b4ea..93e5610 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -178,7 +178,7 @@ namespace pan
 
     private:
       /* GMIME: X-Face interval between spaces for proper folding. */
-      enum { GMIME_FOLD_INTERVAL = 72 };
+      enum { GMIME_FOLD_INTERVAL = 72, GMIME_FOLD_BASE64_INTERVAL = 64 };
 
       void add_actions (GtkWidget* box);
       void apply_profile_to_body ();
diff --git a/pan/gui/profiles-dialog.cc b/pan/gui/profiles-dialog.cc
index 2687337..2de939d 100644
--- a/pan/gui/profiles-dialog.cc
+++ b/pan/gui/profiles-dialog.cc
@@ -223,7 +223,14 @@ ProfileDialog :: ProfileDialog (const Data         & data,
     HIG :: workarea_add_row (t, &row, "",vbox);
 
   HIG :: workarea_add_section_divider (t, &row);
-  HIG :: workarea_add_section_title (t, &row, _("X-Face (Avatar)"));
+
+  HIG :: workarea_add_section_title (t, &row, _("Avatars"));
+    w = _face_entry = gtk_entry_new ();
+    set_entry (w, profile.face);
+    gtk_widget_set_tooltip_markup (w, _("You can add an avatar icon to your articles with a Base64-encoded 
PNG.\n"
+                                        "Add the Base64-encoded picture without the trailing 
<b>“Face:”</b>."));
+    HIG :: workarea_add_row (t, &row, _("_Face:"), w, NULL);
+
     w = _xface_entry = gtk_entry_new ();
     set_entry (w, profile.xface);
     gtk_widget_set_tooltip_markup (w, _("You can add an avatar icon to your articles with a unique X-Face 
code.\n"
@@ -341,6 +348,7 @@ ProfileDialog :: get_profile (std::string& profile_name, Profile& profile)
   from_entry (_username_entry, profile.username);
   from_entry (_address_entry, profile.address);
   from_entry (_msgid_fqdn_entry, profile.fqdn);
+  from_entry (_face_entry, profile.face);
   from_entry (_xface_entry, profile.xface);
   from_entry (_attribution_entry, profile.attribution);
 
diff --git a/pan/gui/profiles-dialog.h b/pan/gui/profiles-dialog.h
index 8f9cfa3..eca62d8 100644
--- a/pan/gui/profiles-dialog.h
+++ b/pan/gui/profiles-dialog.h
@@ -43,6 +43,7 @@ namespace pan
       GtkWidget * _username_entry;
       GtkWidget * _address_entry;
       GtkWidget * _msgid_fqdn_entry;
+      GtkWidget * _face_entry;
       GtkWidget * _xface_entry;
       GtkWidget * _attribution_entry;
       GtkWidget * _signature_file_check;


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