Commit 09aec598 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

wbemprox: Add a partial implementation of Win32_Printer.

parent 64823801
MODULE = wbemprox.dll MODULE = wbemprox.dll
IMPORTS = version iphlpapi dxgi oleaut32 ole32 advapi32 user32 gdi32 ws2_32 IMPORTS = winspool version iphlpapi dxgi oleaut32 ole32 advapi32 user32 gdi32 ws2_32
C_SRCS = \ C_SRCS = \
builtin.c \ builtin.c \
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "winver.h" #include "winver.h"
#include "sddl.h" #include "sddl.h"
#include "ntsecapi.h" #include "ntsecapi.h"
#include "winspool.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wbemprox_private.h" #include "wbemprox_private.h"
...@@ -84,6 +85,8 @@ static const WCHAR class_physicalmemoryW[] = ...@@ -84,6 +85,8 @@ static const WCHAR class_physicalmemoryW[] =
{'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0}; {'W','i','n','3','2','_','P','h','y','s','i','c','a','l','M','e','m','o','r','y',0};
static const WCHAR class_qualifiersW[] = static const WCHAR class_qualifiersW[] =
{'_','_','Q','U','A','L','I','F','I','E','R','S',0}; {'_','_','Q','U','A','L','I','F','I','E','R','S',0};
static const WCHAR class_printerW[] =
{'W','i','n','3','2','_','P','r','i','n','t','e','r',0};
static const WCHAR class_process_getowner_outW[] = static const WCHAR class_process_getowner_outW[] =
{'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W', {'_','_','W','I','N','3','2','_','P','R','O','C','E','S','S','_','G','E','T','O','W',
'N','E','R','_','O','U','T',0}; 'N','E','R','_','O','U','T',0};
...@@ -114,6 +117,8 @@ static const WCHAR prop_adaptertypeW[] = ...@@ -114,6 +117,8 @@ static const WCHAR prop_adaptertypeW[] =
{'A','d','a','p','t','e','r','T','y','p','e',0}; {'A','d','a','p','t','e','r','T','y','p','e',0};
static const WCHAR prop_addresswidthW[] = static const WCHAR prop_addresswidthW[] =
{'A','d','d','r','e','s','s','W','i','d','t','h',0}; {'A','d','d','r','e','s','s','W','i','d','t','h',0};
static const WCHAR prop_attributesW[] =
{'A','t','t','r','i','b','u','t','e','s',0};
static const WCHAR prop_availabilityW[] = static const WCHAR prop_availabilityW[] =
{'A','v','a','i','l','a','b','i','l','i','t','y',0}; {'A','v','a','i','l','a','b','i','l','i','t','y',0};
static const WCHAR prop_binaryrepresentationW[] = static const WCHAR prop_binaryrepresentationW[] =
...@@ -174,6 +179,8 @@ static const WCHAR prop_domainroleW[] = ...@@ -174,6 +179,8 @@ static const WCHAR prop_domainroleW[] =
{'D','o','m','a','i','n','R','o','l','e',0}; {'D','o','m','a','i','n','R','o','l','e',0};
static const WCHAR prop_driveW[] = static const WCHAR prop_driveW[] =
{'D','r','i','v','e',0}; {'D','r','i','v','e',0};
static const WCHAR prop_drivernameW[] =
{'D','r','i','v','e','r','N','a','m','e',0};
static const WCHAR prop_driverversionW[] = static const WCHAR prop_driverversionW[] =
{'D','r','i','v','e','r','V','e','r','s','i','o','n',0}; {'D','r','i','v','e','r','V','e','r','s','i','o','n',0};
static const WCHAR prop_drivetypeW[] = static const WCHAR prop_drivetypeW[] =
...@@ -188,6 +195,8 @@ static const WCHAR prop_freespaceW[] = ...@@ -188,6 +195,8 @@ static const WCHAR prop_freespaceW[] =
{'F','r','e','e','S','p','a','c','e',0}; {'F','r','e','e','S','p','a','c','e',0};
static const WCHAR prop_handleW[] = static const WCHAR prop_handleW[] =
{'H','a','n','d','l','e',0}; {'H','a','n','d','l','e',0};
static const WCHAR prop_horizontalresolutionW[] =
{'H','o','r','i','z','o','n','t','a','l','R','e','s','o','l','u','t','i','o','n',0};
static const WCHAR prop_idW[] = static const WCHAR prop_idW[] =
{'I','D',0}; {'I','D',0};
static const WCHAR prop_identificationcodeW[] = static const WCHAR prop_identificationcodeW[] =
...@@ -210,6 +219,8 @@ static const WCHAR prop_ipenabledW[] = ...@@ -210,6 +219,8 @@ static const WCHAR prop_ipenabledW[] =
{'I','P','E','n','a','b','l','e','d',0}; {'I','P','E','n','a','b','l','e','d',0};
static const WCHAR prop_lastbootuptimeW[] = static const WCHAR prop_lastbootuptimeW[] =
{'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0}; {'L','a','s','t','B','o','o','t','U','p','T','i','m','e',0};
static const WCHAR prop_localW[] =
{'L','o','c','a','l',0};
static const WCHAR prop_localdatetimeW[] = static const WCHAR prop_localdatetimeW[] =
{'L','o','c','a','l','D','a','t','e','T','i','m','e',0}; {'L','o','c','a','l','D','a','t','e','T','i','m','e',0};
static const WCHAR prop_localeW[] = static const WCHAR prop_localeW[] =
...@@ -230,6 +241,8 @@ static const WCHAR prop_modelW[] = ...@@ -230,6 +241,8 @@ static const WCHAR prop_modelW[] =
{'M','o','d','e','l',0}; {'M','o','d','e','l',0};
static const WCHAR prop_netconnectionstatusW[] = static const WCHAR prop_netconnectionstatusW[] =
{'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0}; {'N','e','t','C','o','n','n','e','c','t','i','o','n','S','t','a','t','u','s',0};
static const WCHAR prop_networkW[] =
{'N','e','t','w','o','r','k',0};
static const WCHAR prop_numcoresW[] = static const WCHAR prop_numcoresW[] =
{'N','u','m','b','e','r','O','f','C','o','r','e','s',0}; {'N','u','m','b','e','r','O','f','C','o','r','e','s',0};
static const WCHAR prop_numlogicalprocessorsW[] = static const WCHAR prop_numlogicalprocessorsW[] =
...@@ -488,6 +501,15 @@ static const struct column col_physicalmemory[] = ...@@ -488,6 +501,15 @@ static const struct column col_physicalmemory[] =
{ {
{ prop_capacityW, CIM_UINT64 } { prop_capacityW, CIM_UINT64 }
}; };
static const struct column col_printer[] =
{
{ prop_attributesW, CIM_UINT32 },
{ prop_drivernameW, CIM_STRING|COL_FLAG_DYNAMIC },
{ prop_horizontalresolutionW, CIM_UINT32 },
{ prop_localW, CIM_BOOLEAN },
{ prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC },
{ prop_networkW, CIM_BOOLEAN }
};
static const struct column col_process[] = static const struct column col_process[] =
{ {
{ prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC }, { prop_captionW, CIM_STRING|COL_FLAG_DYNAMIC },
...@@ -844,6 +866,15 @@ struct record_physicalmemory ...@@ -844,6 +866,15 @@ struct record_physicalmemory
{ {
UINT64 capacity; UINT64 capacity;
}; };
struct record_printer
{
UINT32 attributes;
const WCHAR *drivername;
UINT32 horizontalresolution;
int local;
const WCHAR *name;
int network;
};
struct record_process struct record_process
{ {
const WCHAR *caption; const WCHAR *caption;
...@@ -2043,6 +2074,51 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e ...@@ -2043,6 +2074,51 @@ static enum fill_status fill_physicalmemory( struct table *table, const struct e
return status; return status;
} }
static enum fill_status fill_printer( struct table *table, const struct expr *cond )
{
struct record_printer *rec;
enum fill_status status = FILL_STATUS_UNFILTERED;
PRINTER_INFO_2W *info;
DWORD i, offset = 0, count = 0, size = 0;
EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &size, &count );
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FILL_STATUS_FAILED;
if (!(info = heap_alloc( size ))) return FILL_STATUS_FAILED;
if (!EnumPrintersW( PRINTER_ENUM_LOCAL, NULL, 2, (BYTE *)info, size, &size, &count ))
{
heap_free( info );
return FILL_STATUS_FAILED;
}
if (!resize_table( table, count, sizeof(*rec) ))
{
heap_free( info );
return FILL_STATUS_FAILED;
}
for (i = 0; i < count; i++)
{
rec = (struct record_printer *)(table->data + offset);
rec->attributes = info[i].Attributes;
rec->drivername = heap_strdupW( info[i].pDriverName );
rec->horizontalresolution = info[i].pDevMode->u1.s1.dmPrintQuality;
rec->local = -1;
rec->name = heap_strdupW( info[i].pPrinterName );
rec->network = 0;
if (!match_row( table, i, cond, &status ))
{
free_row_values( table, i );
continue;
}
offset += sizeof(*rec);
}
TRACE("created %u rows\n", count);
table->num_rows = count;
heap_free( info );
return status;
}
static WCHAR *get_cmdline( DWORD process_id ) static WCHAR *get_cmdline( DWORD process_id )
{ {
if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() ); if (process_id == GetCurrentProcessId()) return heap_strdupW( GetCommandLineW() );
...@@ -2721,6 +2797,7 @@ static struct table builtin_classes[] = ...@@ -2721,6 +2797,7 @@ static struct table builtin_classes[] =
{ class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param }, { class_paramsW, SIZEOF(col_param), col_param, SIZEOF(data_param), 0, (BYTE *)data_param },
{ class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia }, { class_physicalmediaW, SIZEOF(col_physicalmedia), col_physicalmedia, SIZEOF(data_physicalmedia), 0, (BYTE *)data_physicalmedia },
{ class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory }, { class_physicalmemoryW, SIZEOF(col_physicalmemory), col_physicalmemory, 0, 0, NULL, fill_physicalmemory },
{ class_printerW, SIZEOF(col_printer), col_printer, 0, 0, NULL, fill_printer },
{ class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process }, { class_processW, SIZEOF(col_process), col_process, 0, 0, NULL, fill_process },
{ class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor }, { class_processorW, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
{ class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor }, { class_processor2W, SIZEOF(col_processor), col_processor, 0, 0, NULL, fill_processor },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment