Skip to content

Commit

Permalink
Add caller name and picture for calls
Browse files Browse the repository at this point in the history
Fixes: bboozzoo#58

Signed-off-by: Jo De Boeck <[email protected]>
  • Loading branch information
grimpy committed Jun 26, 2021
1 parent 81dc247 commit 0ae5fde
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/mconnect/telephony.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,23 @@ class TelephonyHandler : Object, PacketHandlerInterface {

// telephony packets have no time information
var time = new DateTime.now_local ();
number = "%s %s".printf (time.format ("%X"), number);

var notif = new Notify.Notification (summary, number,
"phone");
string info = "";
if (pkt.body.has_member("contactName")) {
info = "%s %s (%s)".printf (time.format ("%X"), pkt.body.get_string_member("contactName"), number);
} else {
info = "%s %s".printf (time.format ("%X"), number);
}
var notif = new Notify.Notification (summary, info, "phone");

if (pkt.body.has_member("phoneThumbnail")) {
var data = GLib.Base64.decode(pkt.body.get_string_member("phoneThumbnail"));
var stream = new MemoryInputStream.from_data( data );
try {
notif.set_icon_from_pixbuf(new Gdk.Pixbuf.from_stream( stream ));
} catch (Error e) {
critical ("failed to load image data: %s", e.message);
}
}
try {
notif.show ();
} catch (Error e) {
Expand Down Expand Up @@ -122,4 +135,4 @@ class TelephonyHandler : Object, PacketHandlerInterface {
public void send_sms (Device dev, string number, string message) {
dev.send (make_sms_packet (number, message));
}
}
}

0 comments on commit 0ae5fde

Please sign in to comment.