Add a stub method to query the time zones
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (push) Successful in 15s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (push) Successful in 15s
				
			This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -33,6 +33,16 @@ for KDE. | ||||
| Then running `dbus-monitor --system` as root can be used to see the | ||||
| communication between the control center and this service. | ||||
|  | ||||
| Messages to the D-Bus service can also be sent with `dbus-send`. For example | ||||
| to get the list of time zones: | ||||
|  | ||||
| ```sh | ||||
| dbus-send --system --print-reply --type=method_call \ | ||||
|   --dest=org.freedesktop.timedate1 \ | ||||
|   /org/freedesktop/timedate1 \ | ||||
|   org.freedesktop.timedate1.ListTimezones | ||||
| ``` | ||||
|  | ||||
| ## Dependencies | ||||
|  | ||||
| - glib | ||||
|   | ||||
| @@ -23,5 +23,8 @@ | ||||
|    <arg name="use_ntp" type="b" direction="in"/> | ||||
|    <arg name="user_interaction" type="b" direction="in"/> | ||||
|   </method> | ||||
|   <method name="ListTimezones"> | ||||
|    <arg name="timezones" type="as" direction="out"/> | ||||
|   </method> | ||||
|  </interface> | ||||
| </node> | ||||
|   | ||||
| @@ -33,18 +33,25 @@ static void slack_method_call (GDBusConnection *connection, const gchar *sender, | ||||
| 	gint64 usec_utc; | ||||
|  | ||||
| 	// Set time zone | ||||
| 	if (g_strcmp0 (method_name, "SetTimezone") == 0) { | ||||
|     if (g_strcmp0(method_name, "SetTimezone") == 0) | ||||
|     { | ||||
| 		g_variant_get (parameters, "(&sb)", &timezone, &user_interaction); | ||||
|  | ||||
| 		if (slack_set_timezone (timezone)) g_dbus_method_invocation_return_value (invocation, | ||||
| 				NULL); | ||||
| 		else g_dbus_method_invocation_return_error (invocation, | ||||
| 		if (slack_set_timezone(timezone)) | ||||
|         { | ||||
|             g_dbus_method_invocation_return_value (invocation, NULL); | ||||
|         } | ||||
| 		else | ||||
|         { | ||||
|             g_dbus_method_invocation_return_error (invocation, | ||||
| 				G_IO_ERROR, | ||||
| 				G_IO_ERROR_FAILED, | ||||
| 				"Write operation failed"); | ||||
|  | ||||
|         } | ||||
| 		g_free (timezone); | ||||
|     } else if (g_strcmp0 (method_name, "SetTime") == 0) { | ||||
|     } | ||||
|     else if (g_strcmp0(method_name, "SetTime") == 0) | ||||
|     { | ||||
| 		g_variant_get (parameters, "(xbb)", &usec_utc, &relative, &user_interaction); | ||||
|  | ||||
| 		// Set time | ||||
| @@ -58,18 +65,31 @@ static void slack_method_call (GDBusConnection *connection, const gchar *sender, | ||||
|             g_dbus_method_invocation_return_error(invocation, G_IO_ERROR, G_IO_ERROR_FAILED, | ||||
|                     "Failed to set system clock"); | ||||
|         } | ||||
|     } else if (g_strcmp0 (method_name, "SetNTP") == 0) { | ||||
|     } | ||||
|     else if (g_strcmp0(method_name, "SetNTP") == 0) | ||||
|     { | ||||
| 		g_variant_get (parameters, "(bb)", &use_ntp, &user_interaction); | ||||
|  | ||||
| 		// Enable NTP | ||||
| 		if (slack_set_ntp (use_ntp)) g_dbus_method_invocation_return_value (invocation, | ||||
| 				NULL); | ||||
| 		else g_dbus_method_invocation_return_error (invocation, | ||||
|         if (slack_set_ntp (use_ntp)) | ||||
|         { | ||||
|             g_dbus_method_invocation_return_value (invocation, NULL); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             g_dbus_method_invocation_return_error (invocation, | ||||
| 				G_IO_ERROR, | ||||
| 				G_IO_ERROR_FAILED, | ||||
| 				"Error enabling NTP"); | ||||
|         } | ||||
| 	} | ||||
| 	return; | ||||
|     else if (g_strcmp0(method_name, "ListTimezones") == 0) | ||||
|     { | ||||
|         auto return_value = Glib::Variant<std::vector<Glib::ustring>>::create({}); | ||||
|         auto return_tuple = Glib::Variant<std::vector<Glib::ustring>>::create_tuple({ return_value }); | ||||
|  | ||||
|         g_dbus_method_invocation_return_value(invocation, return_tuple.gobj()); | ||||
|     } | ||||
| } | ||||
|  | ||||
| static GVariant *slack_get_property (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *prop_name, GError **slack_err, gpointer user_data) { | ||||
|   | ||||
| @@ -48,6 +48,9 @@ | ||||
| 	"   <arg name=\"use_ntp\" type=\"b\" direction=\"in\"/>\n"      \ | ||||
| 	"   <arg name=\"user_interaction\" type=\"b\" direction=\"in\"/>\n" \ | ||||
| 	"  </method>\n"                                                 \ | ||||
| 	"  <method name=\"ListTimezones\">\n"                           \ | ||||
| 	"   <arg name=\"timezones\" type=\"as\" direction=\"out\"/>\n"  \ | ||||
| 	"  </method>"                                                   \ | ||||
| 	" </interface>\n"												\ | ||||
| 	"</node>\n" | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user