Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind 2 high visibility PrintCore APIs #4933

Merged
merged 3 commits into from
Oct 11, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/PrintCore/PrintCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,26 @@ public bool IsRemote {
}
}

[DllImport (Constants.PrintCoreLibrary)]
extern static IntPtr PMPrinterGetID (IntPtr printer);

public string ID {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id -> it's not an acronym

get {
return CFString.FetchString (PMPrinterGetID (handle));
Copy link
Contributor Author

@chamons chamons Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not , true as https://developer.apple.com/documentation/applicationservices/1459606-pmprintergetid?language=objc has:

You should not release the string without first retaining it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you need to comment your own PR, before reviews, then it's a good sign those should be comment in the code ;-)

}
}

[DllImport (Constants.PrintCoreLibrary)]
extern static PMStatusCode PMPrinterCopyHostName (IntPtr printer, out IntPtr hostName);

public string HostName {
get {
PMStatusCode code = PMPrinterCopyHostName (handle, out IntPtr hostName);
if (code != PMStatusCode.Ok)
return null;
return CFString.FetchString (hostName, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Releases as https://developer.apple.com/documentation/applicationservices/1462076-pmprintercopyhostname says:

You are responsible for releasing the string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

}
}
}

public class PMServer : PMPrintCoreBase {
Expand Down