Merge lp:~shnatsel/granite/get_contracts_for_files into lp:~elementary-pantheon/granite/granite
Proposed by
Sergey "Shnatsel" Davidoff
Status: | Merged |
---|---|
Approved by: | Sergey "Shnatsel" Davidoff |
Approved revision: | 645 |
Merged at revision: | 639 |
Proposed branch: | lp:~shnatsel/granite/get_contracts_for_files |
Merge into: | lp:~elementary-pantheon/granite/granite |
Diff against target: |
21 lines (+2/-2) 1 file modified
lib/Services/ContractorProxy.vala (+2/-2) |
To merge this branch: | bzr merge lp:~shnatsel/granite/get_contracts_for_files |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Victor Martinez (community) | Approve | ||
Sergey "Shnatsel" Davidoff (community) | Approve | ||
Review via email: mp+188432@code.launchpad.net |
Commit message
files passed to get_contracts_
Description of the change
Add two convenience funtions on top of current Contractor API that allow querying available contracts for files instead of mimetypes. This spares developers of applications that deal with more or less arbitrary files the need to look up the mimetype themselves.
To post a comment you must log in.
As you've mentioned, this will ease the addition of Contractor support for new (or lazy) developers.
The error-handling here is really decent IMO. If the code fails to determine the mime type of any given file, it's OK to let the caller know by aborting the method, instead of returning invalid contracts.
Needs fixing:
1) There's no need to add these new methods to the Contractor DBus interface (Diff lines 8 and 9), as they are not executed by the daemon, nor invoked through DBus.
Some things that could be changed:
2) Avoid code duplication in get_contracts_ for_file by just calling "get_contracts_ for_files" with a single-member array. Like this:
public static Gee.List<Contract> get_contracts_ for_file (File file) throws Error { for_files (files);
File[] files = { file };
return get_contracts_
}
3) I guess there should be a single space after "get_content_type" (diff line 58)
Everything else looks good to me. Thanks for your work!