[rygel] core: Refactor two new methods of ContentDirectory
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Refactor two new methods of ContentDirectory
- Date: Fri, 19 Feb 2010 16:32:46 +0000 (UTC)
commit aa90ed231ac84164d2228a454cfba44c01d52131
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Feb 19 14:30:00 2010 +0200
core: Refactor two new methods of ContentDirectory
Refactor get_transfer_progress_cb & stop_transfer_resource_cb methods of
ContentDirectory.
src/rygel/rygel-content-directory.vala | 80 ++++++++++++++++----------------
1 files changed, 40 insertions(+), 40 deletions(-)
---
diff --git a/src/rygel/rygel-content-directory.vala b/src/rygel/rygel-content-directory.vala
index 4484fc8..d4bf850 100644
--- a/src/rygel/rygel-content-directory.vala
+++ b/src/rygel/rygel-content-directory.vala
@@ -192,55 +192,36 @@ public class Rygel.ContentDirectory: Service {
private virtual void get_transfer_progress_cb (
ContentDirectory content_dir,
owned ServiceAction action) {
- uint32 transfer_id;
-
- action.get ("TransferID",
- typeof (uint32),
- out transfer_id);
-
- foreach (var import in this.active_imports) {
- if (import.transfer_id == transfer_id) {
- action.set ("TransferStatus",
- typeof (string),
- import.status_as_string,
- "TransferLength",
- typeof (int64),
- import.bytes_copied,
- "TransferTotal",
- typeof (int64),
- import.bytes_total);
- action.return ();
-
- return;
- }
+ var import = find_import_for_action (action);
+ if (import != null) {
+ action.set ("TransferStatus",
+ typeof (string),
+ import.status_as_string,
+ "TransferLength",
+ typeof (int64),
+ import.bytes_copied,
+ "TransferTotal",
+ typeof (int64),
+ import.bytes_total);
+
+ action.return ();
+ } else {
+ action.return_error (717, "No such file transfer");
}
-
- // Reaching here means we didn't find the transfer of interest
- action.return_error (717, "No such file transfer");
}
/* StopTransferResource action implementation */
private virtual void stop_transfer_resource_cb (
ContentDirectory content_dir,
owned ServiceAction action) {
- uint32 transfer_id;
-
- action.get ("TransferID",
- typeof (uint32),
- out transfer_id);
-
- foreach (var import in this.active_imports) {
- if (import.transfer_id == transfer_id) {
- import.cancellable.cancel ();
+ var import = find_import_for_action (action);
+ if (import != null) {
+ import.cancellable.cancel ();
- action.return ();
-
- return;
- }
+ action.return ();
+ } else {
+ action.return_error (717, "No such file transfer");
}
-
- // Reaching here means we didn't find the transfer of interest
- action.return_error (717, "No such file transfer");
}
/* GetSystemUpdateID action implementation */
@@ -410,5 +391,24 @@ public class Rygel.ContentDirectory: Service {
return false;
});
}
+
+ private ImportResource? find_import_for_action (ServiceAction action) {
+ ImportResource ret = null;
+ uint32 transfer_id;
+
+ action.get ("TransferID",
+ typeof (uint32),
+ out transfer_id);
+
+ foreach (var import in this.active_imports) {
+ if (import.transfer_id == transfer_id) {
+ ret = import;
+
+ break;
+ }
+ }
+
+ return ret;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]