Bug 40828 - [Binding] Core Printing API
Summary: [Binding] Core Printing API
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: Library (Xamarin.Mac.dll) ()
Version: Master
Hardware: PC Mac OS
: Normal normal
Target Milestone: master
Assignee: Bugzilla
URL:
: 44434 ()
Depends on:
Blocks:
 
Reported: 2016-05-03 16:10 UTC by Sparksteam
Modified: 2017-02-14 14:06 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Sparksteam 2016-05-03 16:10:07 UTC
As advised by the Xamarin.Mac team, via Glenn Stephens at Evolve16, I'm requesting that the OS X Core Printing API be exposed via the Xamarin.Mac library. At a minimum, I need the follow APIs.

PMServerCreatePrinterList
PMPrinterCopyDeviceURI
PMPrinterGetMakeNadModelName
PMPrinterCopyHostName
PMPrinterCopyDescriptionURL

And of course I'll need the PMPrinter class.

Thanks.
Comment 1 Chris Hamons 2016-05-03 16:18:52 UTC
We'll add it to the binding backlog. However, given our current backlog, it may be multiple releases until we get to it.

PMServerCreatePrinterList and friends are simple'ish C functions passing around opaque types, so it might be simple to hack in the p/invokes to do it yourself. 

Feel free to drop by our gitter channel if you want to hack on the actual binding yourself.

Also, we need to add NSPrintInfo it appears.
Comment 2 Sparksteam 2016-05-03 16:22:12 UTC
Thanks Chris. If I were to do it myself, I'd prefer to create a Mac Binding class library with the upcoming, shiny new Xamarin 6 rather than hack. Any idea when it will be officially released?
Comment 3 Chris Hamons 2016-05-03 16:25:26 UTC
Writing a binding project to bind to the actual system libraries isn't a use case we've tested / covered before. It might work (never tried it).

The best source for "when are we going to release X" is the release blog:

https://releases.xamarin.com/evolve-keynote-releases/

suggests

Cycle 7 – May 2016

so likely endish of month if everything goes well.
Comment 4 Sparksteam 2016-05-03 16:27:49 UTC
So exposing them in the Xamarin.Mac dll is not something you guys would consider at the present time?
Comment 5 Chris Hamons 2016-05-03 16:30:09 UTC
No, we absolutely will (at some point) add them to Xamarin.Mac. They are legitimate missing binding.

It just will take awhile to do so, given our current backlog of missing binding. I just wanted to set expectations correctly not to expect them in our next release, and note possible work arounds until then.
Comment 6 Sparksteam 2016-05-03 16:32:21 UTC
Understood Chris, thanks.
Comment 7 Chris Hamons 2017-01-03 20:58:12 UTC
*** Bug 44434 has been marked as a duplicate of this bug. ***
Comment 8 Chris Hamons 2017-01-03 21:04:50 UTC
This was done in:

3133f362b72ff4662741a978cf2b8c6033f45b04
and 
481a79aab5547e13c3e8e3e721b8799e48d75847

and should be in Cycle 10.

QA - You can see the API bound in the PrintCore namespace.
Comment 9 Xavier Rigau 2017-02-13 20:50:26 UTC
I am in need of this functionality too. I guess I'll have to wait two more cycles.
Comment 10 Chris Hamons 2017-02-13 23:00:43 UTC
You are welcome to try out master builds:

https://jenkins.mono-project.com/view/Xamarin.MaciOS/job/xamarin-macios-builds-master/

and see if it works for your use case.

But yes, there was too little testing for it to make C9.

I expect that C9 -> next release will be much shorter than C8->C9 as well.
Comment 11 Xavier Rigau 2017-02-14 01:00:06 UTC
What are the differences TryGetDeviceUrl method vs. DeviceUrl property? Is there any way to access the driver from a PMPrinter object?
Comment 12 Chris Hamons 2017-02-14 14:06:09 UTC
You can see the implementation here:

https://github.com/xamarin/xamarin-macios/blob/master/src/PrintCore/PrintCore.cs#L556

But roughly, the try variant gives you the error code explaining why it failed if it did.

I'm not sure on the second question, I'm not knowledgeable about the specifics of the API. However, I didn't see an API that sounded like it handled that (do you know if there is a PrintCore API for that?)