xref: /haiku/src/preferences/printers/Globals.cpp (revision 1deede7388b04dbeec5af85cae7164735ea9e70d)
1 /*
2  * Copyright 2001-2016, Haiku.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Michael Pfeiffer
7  */
8 
9 
10 #include "Globals.h"
11 
12 #include <stdio.h>
13 
14 #include <Roster.h>
15 
16 #include "pr_server.h"
17 
18 
19 BString
20 ActivePrinterName()
21 {
22 	BMessenger msgr;
23 	if (GetPrinterServerMessenger(msgr) != B_OK)
24 		return BString();
25 
26 	BMessage getNameOfActivePrinter(B_GET_PROPERTY);
27 	getNameOfActivePrinter.AddSpecifier("ActivePrinter");
28 
29 	BMessage reply;
30 	msgr.SendMessage(&getNameOfActivePrinter, &reply);
31 
32 	BString activePrinterName;
33 	reply.FindString("result", &activePrinterName);
34 
35 	return activePrinterName;
36 }
37 
38 
39 status_t
40 GetPrinterServerMessenger(BMessenger& msgr)
41 {
42 	msgr = BMessenger(PSRV_SIGNATURE_TYPE);
43 	return msgr.IsValid() ? B_OK : B_ERROR;
44 }
45