VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibVideo.cpp@ 72352

Last change on this file since 72352 was 72352, checked in by vboxsync, 7 years ago

Main, VMMDev: implemented IDisplay::SetScreenLayout, VMMDev multimonitor resize request and VBoxManage controlvm setscreenlayout. bugref:8393

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 21.1 KB
Line 
1/* $Id: VBoxGuestR3LibVideo.cpp 72352 2018-05-26 12:37:50Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, Video.
4 */
5
6/*
7 * Copyright (C) 2007-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "VBoxGuestR3LibInternal.h"
32
33#include <VBox/log.h>
34#include <VBox/HostServices/GuestPropertySvc.h> /* For Save and RetrieveVideoMode */
35#include <iprt/assert.h>
36#if !defined(VBOX_VBGLR3_XFREE86) && !defined(VBOX_VBGLR3_XORG)
37# include <iprt/mem.h>
38#endif
39#include <iprt/string.h>
40
41#include <stdio.h>
42
43#ifdef VBOX_VBGLR3_XFREE86
44/* Rather than try to resolve all the header file conflicts, I will just
45 prototype what we need here. */
46extern "C" void* xf86memcpy(void*,const void*,xf86size_t);
47# undef memcpy
48# define memcpy xf86memcpy
49extern "C" void* xf86memset(const void*,int,xf86size_t);
50# undef memset
51# define memset xf86memset
52#endif /* VBOX_VBGLR3_XFREE86 */
53
54#define VIDEO_PROP_PREFIX "/VirtualBox/GuestAdd/Vbgl/Video/"
55
56/**
57 * Enable or disable video acceleration.
58 *
59 * @returns VBox status code.
60 *
61 * @param fEnable Pass zero to disable, any other value to enable.
62 */
63VBGLR3DECL(int) VbglR3VideoAccelEnable(bool fEnable)
64{
65 VMMDevVideoAccelEnable Req;
66 vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelEnable);
67 Req.u32Enable = fEnable;
68 Req.cbRingBuffer = VMMDEV_VBVA_RING_BUFFER_SIZE;
69 Req.fu32Status = 0;
70 return vbglR3GRPerform(&Req.header);
71}
72
73
74/**
75 * Flush the video buffer.
76 *
77 * @returns VBox status code.
78 */
79VBGLR3DECL(int) VbglR3VideoAccelFlush(void)
80{
81 VMMDevVideoAccelFlush Req;
82 vmmdevInitRequest(&Req.header, VMMDevReq_VideoAccelFlush);
83 return vbglR3GRPerform(&Req.header);
84}
85
86
87/**
88 * Send mouse pointer shape information to the host.
89 *
90 * @returns VBox status code.
91 *
92 * @param fFlags Mouse pointer flags.
93 * @param xHot X coordinate of hot spot.
94 * @param yHot Y coordinate of hot spot.
95 * @param cx Pointer width.
96 * @param cy Pointer height.
97 * @param pvImg Pointer to the image data (can be NULL).
98 * @param cbImg Size of the image data pointed to by pvImg.
99 */
100VBGLR3DECL(int) VbglR3SetPointerShape(uint32_t fFlags, uint32_t xHot, uint32_t yHot, uint32_t cx, uint32_t cy,
101 const void *pvImg, size_t cbImg)
102{
103 VMMDevReqMousePointer *pReq;
104 size_t cbReq = vmmdevGetMousePointerReqSize(cx, cy);
105 AssertReturn( !pvImg
106 || cbReq == RT_OFFSETOF(VMMDevReqMousePointer, pointerData) + cbImg,
107 VERR_INVALID_PARAMETER);
108 int rc = vbglR3GRAlloc((VMMDevRequestHeader **)&pReq, cbReq, VMMDevReq_SetPointerShape);
109 if (RT_SUCCESS(rc))
110 {
111 pReq->fFlags = fFlags;
112 pReq->xHot = xHot;
113 pReq->yHot = yHot;
114 pReq->width = cx;
115 pReq->height = cy;
116 if (pvImg)
117 memcpy(pReq->pointerData, pvImg, cbImg);
118
119 rc = vbglR3GRPerform(&pReq->header);
120 if (RT_SUCCESS(rc))
121 rc = pReq->header.rc;
122 vbglR3GRFree(&pReq->header);
123 }
124 return rc;
125}
126
127
128/**
129 * Send mouse pointer shape information to the host.
130 * This version of the function accepts a request for clients that
131 * already allocate and manipulate the request structure directly.
132 *
133 * @returns VBox status code.
134 *
135 * @param pReq Pointer to the VMMDevReqMousePointer structure.
136 */
137VBGLR3DECL(int) VbglR3SetPointerShapeReq(VMMDevReqMousePointer *pReq)
138{
139 int rc = vbglR3GRPerform(&pReq->header);
140 if (RT_SUCCESS(rc))
141 rc = pReq->header.rc;
142 return rc;
143}
144
145
146/**
147 * Query the last display change request sent from the host to the guest.
148 *
149 * @returns iprt status value
150 * @param pcx Where to store the horizontal pixel resolution
151 * @param pcy Where to store the vertical pixel resolution
152 * requested (a value of zero means do not change).
153 * @param pcBits Where to store the bits per pixel requested (a value
154 * of zero means do not change).
155 * @param piDisplay Where to store the display number the request was for
156 * - 0 for the primary display, 1 for the first
157 * secondary display, etc.
158 * @param fAck whether or not to acknowledge the newest request sent by
159 * the host. If this is set, the function will return the
160 * most recent host request, otherwise it will return the
161 * last request to be acknowledged.
162 *
163 */
164static int getDisplayChangeRequest2(uint32_t *pcx, uint32_t *pcy,
165 uint32_t *pcBits, uint32_t *piDisplay,
166 bool fAck)
167{
168 VMMDevDisplayChangeRequest2 Req;
169
170 AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
171 AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
172 AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
173 AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
174 RT_ZERO(Req);
175 vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequest2);
176 if (fAck)
177 Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
178 int rc = vbglR3GRPerform(&Req.header);
179 if (RT_SUCCESS(rc))
180 rc = Req.header.rc;
181 if (RT_SUCCESS(rc))
182 {
183 *pcx = Req.xres;
184 *pcy = Req.yres;
185 *pcBits = Req.bpp;
186 *piDisplay = Req.display;
187 }
188 return rc;
189}
190
191
192/**
193 * Query the last display change request sent from the host to the guest.
194 *
195 * @returns iprt status value
196 * @param pcx Where to store the horizontal pixel resolution
197 * requested (a value of zero means do not change).
198 * @param pcy Where to store the vertical pixel resolution
199 * requested (a value of zero means do not change).
200 * @param pcBits Where to store the bits per pixel requested (a value
201 * of zero means do not change).
202 * @param piDisplay Where to store the display number the request was for
203 * - 0 for the primary display, 1 for the first
204 * secondary display, etc.
205 * @param fAck whether or not to acknowledge the newest request sent by
206 * the host. If this is set, the function will return the
207 * most recent host request, otherwise it will return the
208 * last request to be acknowledged.
209 *
210 * @param pdx New horizontal position of the secondary monitor.
211 * Optional.
212 * @param pdy New vertical position of the secondary monitor.
213 * Optional.
214 * @param pfEnabled Secondary monitor is enabled or not. Optional.
215 * @param pfChangeOrigin Whether the mode hint retrieved included
216 * information about origin/display offset inside the
217 * frame-buffer. Optional.
218 *
219 */
220VBGLR3DECL(int) VbglR3GetDisplayChangeRequest(uint32_t *pcx, uint32_t *pcy,
221 uint32_t *pcBits,
222 uint32_t *piDisplay,
223 uint32_t *pdx, uint32_t *pdy,
224 bool *pfEnabled,
225 bool *pfChangeOrigin,
226 bool fAck)
227{
228 VMMDevDisplayChangeRequestEx Req;
229 int rc = VINF_SUCCESS;
230
231 AssertPtrReturn(pcx, VERR_INVALID_PARAMETER);
232 AssertPtrReturn(pcy, VERR_INVALID_PARAMETER);
233 AssertPtrReturn(pcBits, VERR_INVALID_PARAMETER);
234 AssertPtrNullReturn(pdx, VERR_INVALID_PARAMETER);
235 AssertPtrNullReturn(pdy, VERR_INVALID_PARAMETER);
236 AssertPtrReturn(piDisplay, VERR_INVALID_PARAMETER);
237 AssertPtrNullReturn(pfEnabled, VERR_INVALID_PARAMETER);
238 AssertPtrNullReturn(pfChangeOrigin, VERR_INVALID_PARAMETER);
239
240 RT_ZERO(Req);
241 rc = vmmdevInitRequest(&Req.header, VMMDevReq_GetDisplayChangeRequestEx);
242 AssertRCReturn(rc, rc);
243 if (fAck)
244 Req.eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
245 rc = vbglR3GRPerform(&Req.header);
246 if (RT_SUCCESS(rc))
247 rc = Req.header.rc;
248 if (RT_SUCCESS(rc))
249 {
250 *pcx = Req.xres;
251 *pcy = Req.yres;
252 *pcBits = Req.bpp;
253 *piDisplay = Req.display;
254 if (pdx)
255 *pdx = Req.cxOrigin;
256 if (pdy)
257 *pdy = Req.cyOrigin;
258 if (pfEnabled)
259 *pfEnabled = Req.fEnabled;
260 if (pfChangeOrigin)
261 *pfChangeOrigin = Req.fChangeOrigin;
262 return VINF_SUCCESS;
263 }
264
265 /* NEEDS TESTING: test below with current Additions on VBox 4.1 or older. */
266 /** @todo Can we find some standard grep-able string for "NEEDS TESTING"? */
267 if (rc == VERR_NOT_IMPLEMENTED) /* Fall back to the old API. */
268 {
269 if (pfEnabled)
270 *pfEnabled = true;
271 if (pfChangeOrigin)
272 *pfChangeOrigin = false;
273 return getDisplayChangeRequest2(pcx, pcy, pcBits, piDisplay, fAck);
274 }
275 return rc;
276}
277
278
279/**
280 * Query the last display change request sent from the host to the guest.
281 *
282 * @returns iprt status value
283 * @param cDisplaysIn How many elements in the paDisplays array.
284 * @param pcDisplaysOut How many elements were returned.
285 * @param paDisplays Display information.
286 * @param fAck Whether or not to acknowledge the newest request sent by
287 * the host. If this is set, the function will return the
288 * most recent host request, otherwise it will return the
289 * last request to be acknowledged.
290 */
291VBGLR3DECL(int) VbglR3GetDisplayChangeRequestMulti(uint32_t cDisplaysIn,
292 uint32_t *pcDisplaysOut,
293 VMMDevDisplayDef *paDisplays,
294 bool fAck)
295{
296 VMMDevDisplayChangeRequestMulti *pReq;
297 size_t cbDisplays;
298 size_t cbAlloc;
299 int rc = VINF_SUCCESS;
300
301 AssertReturn(cDisplaysIn > 0 && cDisplaysIn <= 64 /* VBOX_VIDEO_MAX_SCREENS */, VERR_INVALID_PARAMETER);
302 AssertPtrReturn(pcDisplaysOut, VERR_INVALID_PARAMETER);
303 AssertPtrReturn(paDisplays, VERR_INVALID_PARAMETER);
304
305 cbDisplays = cDisplaysIn * sizeof(VMMDevDisplayDef);
306 cbAlloc = RT_UOFFSETOF(VMMDevDisplayChangeRequestMulti, aDisplays) + cbDisplays;
307 pReq = (VMMDevDisplayChangeRequestMulti *)RTMemAllocZ(cbAlloc);
308 AssertPtrReturn(pReq, VERR_NO_MEMORY);
309
310 rc = vmmdevInitRequest(&pReq->header, VMMDevReq_GetDisplayChangeRequestMulti);
311 AssertRCReturnStmt(rc, RTMemFree(pReq), rc);
312
313 pReq->header.size += (uint32_t)cbDisplays;
314 pReq->cDisplays = cDisplaysIn;
315 if (fAck)
316 pReq->eventAck = VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
317
318 rc = vbglR3GRPerform(&pReq->header);
319 AssertRCReturnStmt(rc, RTMemFree(pReq), rc);
320
321 rc = pReq->header.rc;
322 if (RT_SUCCESS(rc))
323 {
324 memcpy(paDisplays, pReq->aDisplays, pReq->cDisplays * sizeof(VMMDevDisplayDef));
325 *pcDisplaysOut = pReq->cDisplays;
326 }
327
328 RTMemFree(pReq);
329 return rc;
330}
331
332
333/**
334 * Query the host as to whether it likes a specific video mode.
335 *
336 * @returns the result of the query
337 * @param cx the width of the mode being queried
338 * @param cy the height of the mode being queried
339 * @param cBits the bpp of the mode being queried
340 */
341VBGLR3DECL(bool) VbglR3HostLikesVideoMode(uint32_t cx, uint32_t cy, uint32_t cBits)
342{
343 bool fRc = true; /* If for some reason we can't contact the host then
344 * we like everything. */
345 int rc;
346 VMMDevVideoModeSupportedRequest req;
347
348 vmmdevInitRequest(&req.header, VMMDevReq_VideoModeSupported);
349 req.width = cx;
350 req.height = cy;
351 req.bpp = cBits;
352 req.fSupported = true;
353 rc = vbglR3GRPerform(&req.header);
354 if (RT_SUCCESS(rc) && RT_SUCCESS(req.header.rc))
355 fRc = req.fSupported;
356 return fRc;
357}
358
359/**
360 * Get the highest screen number for which there is a saved video mode or "0"
361 * if there are no saved modes.
362 *
363 * @returns iprt status value
364 * @returns VERR_NOT_SUPPORTED if the guest property service is not available.
365 * @param pcScreen where to store the virtual screen number
366 */
367VBGLR3DECL(int) VbglR3VideoModeGetHighestSavedScreen(unsigned *pcScreen)
368{
369#if defined(VBOX_WITH_GUEST_PROPS)
370 int rc;
371 HGCMCLIENTID idClient = 0;
372 PVBGLR3GUESTPROPENUM pHandle = NULL;
373 const char *pszName = NULL;
374 unsigned cHighestScreen = 0;
375
376 /* Validate input. */
377 AssertPtrReturn(pcScreen, VERR_INVALID_POINTER);
378
379 /* Query the data. */
380 rc = VbglR3GuestPropConnect(&idClient);
381 if (RT_SUCCESS(rc))
382 {
383 const char *pszPattern = VIDEO_PROP_PREFIX"*";
384 rc = VbglR3GuestPropEnum(idClient, &pszPattern, 1, &pHandle, &pszName, NULL, NULL, NULL);
385 int rc2 = VbglR3GuestPropDisconnect(idClient);
386 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
387 rc = rc2;
388 }
389
390 /* Process the data. */
391 while (RT_SUCCESS(rc) && pszName != NULL)
392 {
393 uint32_t cScreen;
394
395 rc = RTStrToUInt32Full(pszName + sizeof(VIDEO_PROP_PREFIX) - 1, 10, &cScreen);
396 if (RT_SUCCESS(rc)) /* There may be similar properties with text. */
397 cHighestScreen = RT_MAX(cHighestScreen, cScreen);
398 rc = VbglR3GuestPropEnumNext(pHandle, &pszName, NULL, NULL, NULL);
399 }
400
401 VbglR3GuestPropEnumFree(pHandle);
402
403 /* Return result. */
404 if (RT_SUCCESS(rc))
405 *pcScreen = cHighestScreen;
406 return rc;
407#else /* !VBOX_WITH_GUEST_PROPS */
408 return VERR_NOT_SUPPORTED;
409#endif /* !VBOX_WITH_GUEST_PROPS */
410}
411
412/**
413 * Save video mode parameters to the guest property store.
414 *
415 * @returns iprt status value
416 * @param idScreen The virtual screen number.
417 * @param cx mode width
418 * @param cy mode height
419 * @param cBits bits per pixel for the mode
420 * @param x virtual screen X offset
421 * @param y virtual screen Y offset
422 * @param fEnabled is this virtual screen enabled?
423 */
424VBGLR3DECL(int) VbglR3SaveVideoMode(unsigned idScreen, unsigned cx, unsigned cy, unsigned cBits,
425 unsigned x, unsigned y, bool fEnabled)
426{
427#ifdef VBOX_WITH_GUEST_PROPS
428 unsigned cHighestScreen = 0;
429 int rc = VbglR3VideoModeGetHighestSavedScreen(&cHighestScreen);
430 if (RT_SUCCESS(rc))
431 {
432 HGCMCLIENTID idClient = 0;
433 rc = VbglR3GuestPropConnect(&idClient);
434 if (RT_SUCCESS(rc))
435 {
436 int rc2;
437 char szModeName[GUEST_PROP_MAX_NAME_LEN];
438 char szModeParms[GUEST_PROP_MAX_VALUE_LEN];
439 RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX "%u", idScreen);
440 RTStrPrintf(szModeParms, sizeof(szModeParms), "%ux%ux%u,%ux%u,%u", cx, cy, cBits, x, y, (unsigned) fEnabled);
441
442 rc = VbglR3GuestPropWriteValue(idClient, szModeName, szModeParms);
443 /* Write out the mode using the legacy name too, in case the user
444 * re-installs older Additions. */
445 if (idScreen == 0)
446 {
447 RTStrPrintf(szModeParms, sizeof(szModeParms), "%ux%ux%u", cx, cy, cBits);
448 VbglR3GuestPropWriteValue(idClient, VIDEO_PROP_PREFIX "SavedMode", szModeParms);
449 }
450
451 rc2 = VbglR3GuestPropDisconnect(idClient);
452 if (rc != VINF_PERMISSION_DENIED)
453 {
454 if (RT_SUCCESS(rc))
455 rc = rc2;
456 if (RT_SUCCESS(rc))
457 {
458 /* Sanity check 1. We do not try to make allowance for someone else
459 * changing saved settings at the same time as us. */
460 bool fEnabled2 = false;
461 unsigned cx2 = 0;
462 unsigned cy2 = 0;
463 unsigned cBits2 = 0;
464 unsigned x2 = 0;
465 unsigned y2 = 0;
466 rc = VbglR3RetrieveVideoMode(idScreen, &cx2, &cy2, &cBits2, &x2, &y2, &fEnabled2);
467 if ( RT_SUCCESS(rc)
468 && (cx != cx2 || cy != cy2 || cBits != cBits2 || x != x2 || y != y2 || fEnabled != fEnabled2))
469 rc = VERR_WRITE_ERROR;
470 /* Sanity check 2. Same comment. */
471 else if (RT_SUCCESS(rc))
472 {
473 unsigned cHighestScreen2 = 0;
474 rc = VbglR3VideoModeGetHighestSavedScreen(&cHighestScreen2);
475 if (RT_SUCCESS(rc))
476 if (cHighestScreen2 != RT_MAX(cHighestScreen, idScreen))
477 rc = VERR_INTERNAL_ERROR;
478 }
479 }
480 }
481 }
482 }
483 return rc;
484#else /* !VBOX_WITH_GUEST_PROPS */
485 return VERR_NOT_SUPPORTED;
486#endif /* !VBOX_WITH_GUEST_PROPS */
487}
488
489
490/**
491 * Retrieve video mode parameters from the guest property store.
492 *
493 * @returns iprt status value
494 * @param idScreen The virtual screen number.
495 * @param pcx where to store the mode width
496 * @param pcy where to store the mode height
497 * @param pcBits where to store the bits per pixel for the mode
498 * @param px where to store the virtual screen X offset
499 * @param py where to store the virtual screen Y offset
500 * @param pfEnabled where to store whether this virtual screen is enabled
501 */
502VBGLR3DECL(int) VbglR3RetrieveVideoMode(unsigned idScreen,
503 unsigned *pcx, unsigned *pcy,
504 unsigned *pcBits,
505 unsigned *px, unsigned *py,
506 bool *pfEnabled)
507{
508#ifdef VBOX_WITH_GUEST_PROPS
509 /*
510 * First we retrieve the video mode which is saved as a string in the
511 * guest property store.
512 */
513 HGCMCLIENTID idClient = 0;
514 int rc = VbglR3GuestPropConnect(&idClient);
515 if (RT_SUCCESS(rc))
516 {
517 int rc2;
518 /* The buffer for VbglR3GuestPropReadValue. If this is too small then
519 * something is wrong with the data stored in the property. */
520 char szModeParms[1024];
521 char szModeName[GUEST_PROP_MAX_NAME_LEN]; /** @todo add a VbglR3GuestPropReadValueF/FV that does the RTStrPrintf for you. */
522 RTStrPrintf(szModeName, sizeof(szModeName), VIDEO_PROP_PREFIX "%u", idScreen);
523 rc = VbglR3GuestPropReadValue(idClient, szModeName, szModeParms, sizeof(szModeParms), NULL);
524 /* Try legacy single screen name. */
525 if (rc == VERR_NOT_FOUND && idScreen == 0)
526 rc = VbglR3GuestPropReadValue(idClient,
527 VIDEO_PROP_PREFIX"SavedMode",
528 szModeParms, sizeof(szModeParms),
529 NULL);
530 rc2 = VbglR3GuestPropDisconnect(idClient);
531 if (RT_SUCCESS(rc))
532 rc = rc2;
533
534 /*
535 * Now we convert the string returned to numeric values.
536 */
537 if (RT_SUCCESS(rc))
538 {
539 unsigned cx = 0;
540 unsigned cy = 0;
541 unsigned cBits = 0;
542 unsigned x = 0;
543 unsigned y = 0;
544 unsigned fEnabled = 1;
545 char ch1 = 0;
546 char ch2 = 0;
547 int cMatches = sscanf(szModeParms, "%5ux%5ux%2u%c%5ux%5u,%1u%c", &cx, &cy, &cBits, &ch1, &x, &y, &fEnabled, &ch2);
548 if ( (cMatches == 7 && ch1 == ',')
549 || cMatches == 3)
550 {
551 if (pcx)
552 *pcx = cx;
553 if (pcy)
554 *pcy = cy;
555 if (pcBits)
556 *pcBits = cBits;
557 if (px)
558 *px = x;
559 if (py)
560 *py = y;
561 if (pfEnabled)
562 *pfEnabled = RT_BOOL(fEnabled);
563 rc = VINF_SUCCESS;
564 }
565 else if (cMatches < 0)
566 rc = VERR_READ_ERROR;
567 else
568 rc = VERR_PARSE_ERROR;
569 }
570 }
571
572 return rc;
573#else /* !VBOX_WITH_GUEST_PROPS */
574 return VERR_NOT_SUPPORTED;
575#endif /* !VBOX_WITH_GUEST_PROPS */
576}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette