This repository has been archived by the owner on Mar 12, 2024. It is now read-only.
generated from tau-OS/vala-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ meson | |
vala | ||
blueprint-compiler | ||
webkitgtk-6.0 | ||
json-glib-1.0 | ||
``` | ||
|
||
## 🏗️ Building | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
public class SkiffDesktop.MessageHandler { | ||
private class NotificationItem : Object { | ||
public string title { get; set; } | ||
public string body { get; set; } | ||
public string threadID { get; set; } | ||
public string emailID { get; set; } | ||
} | ||
|
||
private class NotificationData : Object { | ||
public NotificationItem[] notificationData { get; set; } | ||
} | ||
|
||
private class UnreadData : Object { | ||
public int numUnread { get; set; } | ||
} | ||
|
||
public void on_script_message (JSC.Value val) { | ||
var parser = new Json.Parser (); | ||
parser.load_from_data (val.to_string ()); | ||
|
||
var root = parser.get_root (); | ||
var message_type = root.get_object ().get_string_member ("type"); | ||
|
||
switch (message_type) { | ||
case "unreadMailCount": | ||
var unread_data = Json.gobject_deserialize (typeof (UnreadData), root) as UnreadData; | ||
assert (unread_data != null); | ||
print ("unread count: %d\n", unread_data.numUnread); | ||
break; | ||
case "newMessageNotifications": | ||
var notification_data = Json.gobject_deserialize (typeof (NotificationData), root) as NotificationData; | ||
assert (notification_data != null); | ||
print ("notifications: %d\n", notification_data.notificationData.length); | ||
break; | ||
default: | ||
print ("Received unknown message %s\n", val.to_string ()); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters