Merge lp:~optimisme/pantheon-files/fix-1184604 into lp:~elementary-apps/pantheon-files/trunk

Proposed by Albert
Status: Merged
Approved by: Victor Martinez
Approved revision: 1212
Merged at revision: 1200
Proposed branch: lp:~optimisme/pantheon-files/fix-1184604
Merge into: lp:~elementary-apps/pantheon-files/trunk
Diff against target: 112 lines (+42/-4)
4 files modified
libcore/gof-file.c (+35/-2)
libcore/gof-file.h (+1/-1)
libcore/marlincore-C.vapi (+3/-0)
src/View/OverlayBar.vala (+3/-1)
To merge this branch: bzr merge lp:~optimisme/pantheon-files/fix-1184604
Reviewer Review Type Date Requested Status
Victor Martinez (community) Approve
Review via email: mp+166085@code.launchpad.net

Commit message

- Local network root overlays
- Network root folder detection
- Open files from "smb" folders

Description of the change

Fixed:

- Local network root overlays
- Network root folder detection
- Open files from "smb" folders
https://bugs.launchpad.net/pantheon-files/+bug/1184977

To post a comment you must log in.
Revision history for this message
Victor Martinez (victored) wrote :

Nice work, as always.

A couple of suggestions (diff lines):

- 26: "else" clause not needed.
- 39, 40: Use g_strdup instead.

I'm not a big fan of the way some things were implemented in GOFFile. Historically, it duplicates a couple of things in memory that are still allocated in GOFFile.info, unnecessarily increasing memory consumption since the latter is not freed. To avoid extending this problem, I'd recommend adding GOFFile.get_target_location_uri to the API, and returning directly the result of: "g_file_info_get_attribute_string (file->info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);" so that the code doesn't duplicate that string (do not free this string since it's owned by GOFFile.info).

- 21 - 29: Some coding style corrections are needed here. Also either documentation or more verbose code would be appreciated. I'd suggest moving that portion of code to a separate function (e.g. is_complete_smb_uri), and documenting what that method does on that function. What I've figured by reading the code is that it verifies the completeness of an URI, and if it doesn't appear to be complete it's treated as root.

review: Needs Fixing
1201. By Albert

last fixes

1202. By Albert

last fixes

Revision history for this message
Albert (optimisme) wrote :

Hi Victor,

I just "small fixed" the source, now I will add the new suggested functions to lower memory and make it more readable.

1203. By Albert

new function to check if an uri is default

Revision history for this message
Albert (optimisme) wrote :

Hi Victor,

I have tried to remove the "target_location_uri" and replace it by a function but I am receiving segmentation faults, so I will leave it with the variable.

1204. By Albert

last fixes

1205. By Albert

last fixes

1206. By Albert

changed variable by function

1207. By Albert

changed variable by function

1208. By Albert

changed variable by function

Revision history for this message
Albert (optimisme) wrote :

I think it accomplishes every suggestion and is ready to be released.

This bug also fixes:
https://bugs.launchpad.net/pantheon-files/+bug/1184977

Revision history for this message
Victor Martinez (victored) wrote :

Albert,

This is looking great so far.

I forgot to mention that GOFFile is a critical part of Pantheon Files and its plugin API, so special care must be taken when modifying the members of the structure, since we want to make sure external plugins (i.e. the ones not re-built along with the core library) are not broken; specially the Dropbox and UbuntuOne plugins. The latter is broken after merging this branch due to the ABI break described below.

Modifying the size of a structure is dangerous, but it doesn't seem to break any of the plugins we know so far. However, inserting structure members in the middle of existing ones does cause breaks, since member indexes are displaced resulting in incorrect pointers being de-referenced. Therefore my only request will be moving the new target_location_uri member to the very bottom of the _GOFFile structure.

On another topic, gof_file_is_location_uri_default should not be publicly exposed. Please remove it from gof-file.h and make it a static function in gof-file.c. I like what you did with the implementation of this method; just make sure the comment follows this style: http://bazaar.launchpad.net/~elementary-apps/pantheon-files/trunk/view/head:/libcore/eel-fcts.c#L99

I have not tried this at home, but could you please tell me if this doesn't produce the same results:

112 + if (goffile.is_network_uri_scheme ()) {
113 + status.set_label (goffile.get_target_location ().get_uri ());
114 + } else if (!goffile.is_folder ()) {

...?

review: Needs Fixing
1209. By Albert

static method is_location_uri_default

Revision history for this message
Albert (optimisme) wrote :

Hi Victor,

- status.set_label (goffile.get_target_location ().get_uri ()), produces something like "network://dnsssd-domain-Backups._afpovertcp._tcp/", it is just what we are trying to prevent.

- target_location_uri is not in the source anymore, because the new function "gof_file_get_standard_target_uri" is being used

- "gof_file_get_standard_target_uri" has been removed from "gof-file.h", has been made static and moved "up" with the other static functions.

- "gof_file_get_standard_target_uri" the comments has been copied from the suggested source (one of the 3 types of comments there)

1210. By Albert

function moved at the bottom of the .h file

Revision history for this message
Albert (optimisme) wrote :

Sorry, the new static function is "gof_file_is_location_uri_default", "gof_file_get_standard_target_uri" has been moved at the bottom of the "gof-file.h" file to prevent plugins problems.

1211. By Albert

get_standard_target_uri moved at the bottom of marlincor-C space

Revision history for this message
Victor Martinez (victored) wrote :

Great work Albert!

Final suggestions:

- Remove extra line from comment (diff line 9)

- Add back diff line 53 (revert change at diff line 54)

- get_standard_target_uri => get_display_target_uri. (diff line 63. Also add space before parenthesis).
  * For the implementation, please use "return g_file_info_get_attribute_as_string (file->info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);" instead so that the string is properly formatted in UTF-8 as expected by GTK+. There's no need to call g_strdup on it's return value.
  * in marlincore-C.vapi, make sure to define the return value as "unowned" so that no Vala code frees the string. This would look like: "public unowned string get_display_target_uri ();"

It's 3:47 am here so I may go away to sleep for a couple of hours. I'll review and test the branch right away when I get back. I'm sure I'll be marking it as approved :)

Thank you very much for your work!!

1212. By Albert

linal fixes

Revision history for this message
Victor Martinez (victored) wrote :

Albert,

Excellent work!

Everything work well here so far. I'm happy because your code doesn't break the core library ABI :)

review: Approve
Revision history for this message
Albert (optimisme) wrote :

Thanks Victor, I hope it is released soon.

Revision history for this message
Victor Martinez (victored) wrote :

We expect the new package to be ready in less than 2 days.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libcore/gof-file.c'
2--- libcore/gof-file.c 2013-05-28 07:25:28 +0000
3+++ libcore/gof-file.c 2013-05-29 10:01:27 +0000
4@@ -191,6 +191,30 @@
5 return FALSE;
6 }
7
8+/**
9+ * gof_file_is_location_uri_default:
10+ *
11+ * Returns true if it is an uri at "/"
12+ * (example: afp://server.local:123/)
13+ *
14+**/
15+static gboolean
16+gof_file_is_location_uri_default (GOFFile *file)
17+{
18+ char* target_location_uri = gof_file_get_display_target_uri (file);
19+ if (target_location_uri != NULL) {
20+ gchar **split = g_strsplit (target_location_uri, "/", 4);
21+ if (split[3] == NULL || !strcmp (split[3], "")) {
22+ g_strfreev (split);
23+ g_free (target_location_uri);
24+ return TRUE;
25+ }
26+ g_strfreev (split);
27+ }
28+ g_free (target_location_uri);
29+ return FALSE;
30+}
31+
32 gboolean
33 gof_file_is_remote_uri_scheme (GOFFile *file)
34 {
35@@ -204,8 +228,10 @@
36 gboolean
37 gof_file_is_root_network_folder (GOFFile *file)
38 {
39- return gof_file_is_network_uri_scheme (file)
40- || gof_file_is_smb_uri_scheme (file);
41+ if (gof_file_is_network_uri_scheme (file))
42+ return TRUE;
43+
44+ return (gof_file_is_smb_uri_scheme (file) && gof_file_is_location_uri_default (file));
45 }
46
47 gboolean
48@@ -2376,6 +2402,13 @@
49 return NULL;
50 }
51
52+char *
53+gof_file_get_display_target_uri (GOFFile* file)
54+{
55+ return g_file_info_get_attribute_as_string (file->info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI);
56+}
57+
58+
59 const gchar *
60 gof_file_get_preview_path(GOFFile* file)
61 {
62
63=== modified file 'libcore/gof-file.h'
64--- libcore/gof-file.h 2013-05-27 22:20:15 +0000
65+++ libcore/gof-file.h 2013-05-29 10:01:27 +0000
66@@ -233,7 +233,6 @@
67 * Return value: the #GOFFileThumbState for @file.
68 **/
69 #define gof_file_get_thumb_state(file) (GOF_FILE ((file))->flags & GOF_FILE_THUMB_STATE_MASK)
70-
71 const gchar* gof_file_get_thumbnail_path (GOFFile *file);
72 const gchar* gof_file_get_preview_path (GOFFile *file);
73 gboolean gof_file_can_set_owner (GOFFile *file);
74@@ -258,6 +257,7 @@
75 gboolean gof_file_is_smb_uri_scheme (GOFFile *file);
76 gboolean gof_file_thumb_can_frame (GOFFile *file);
77
78+char *gof_file_get_display_target_uri (GOFFile* file);
79 G_END_DECLS
80
81 #endif /* GOF_DIRECTORY_ASYNC_H */
82
83=== modified file 'libcore/marlincore-C.vapi'
84--- libcore/marlincore-C.vapi 2013-05-27 10:54:46 +0000
85+++ libcore/marlincore-C.vapi 2013-05-29 10:01:27 +0000
86@@ -196,8 +196,11 @@
87 public static int compare_by_display_name (File file1, File file2);
88
89 public bool is_remote_uri_scheme ();
90+ public bool is_root_network_folder ();
91 public bool is_network_uri_scheme ();
92 public bool is_smb_uri_scheme ();
93+
94+ public unowned string get_display_target_uri ();
95 }
96
97 [CCode (cheader_filename = "gof-file.h")]
98
99=== modified file 'src/View/OverlayBar.vala'
100--- src/View/OverlayBar.vala 2013-05-12 05:27:30 +0000
101+++ src/View/OverlayBar.vala 2013-05-29 10:01:27 +0000
102@@ -215,7 +215,9 @@
103 private void update_status ()
104 {
105 if (count == 1) {
106- if (!goffile.is_folder ()) {
107+ if (goffile.is_network_uri_scheme ()) {
108+ status.set_label (goffile.get_display_target_uri ());
109+ } else if (!goffile.is_folder ()) {
110 status.set_label ("%s - %s (%s)".printf (goffile.info.get_name (), goffile.formated_type, goffile.format_size));
111 } else {
112 status.set_label ("%s - %s".printf (goffile.info.get_name (), goffile.formated_type));

Subscribers

People subscribed via source and target branches

to all changes: