| 1 | package com.github.markusbernhardt.proxy.jna.win; |
| 2 | |
| 3 | import java.util.Arrays; |
| 4 | import java.util.List; |
| 5 | |
| 6 | import com.sun.jna.Pointer; |
| 7 | import com.sun.jna.Structure; |
| 8 | import com.sun.jna.platform.win32.WTypes; |
| 9 | import com.sun.jna.platform.win32.WinDef; |
| 10 | |
| 11 | /** |
| 12 | * The WINHTTP_PROXY_INFO structure contains the session or default proxy |
| 13 | * configuration. |
| 14 | * |
| 15 | * @author Markus Bernhardt, Copyright 2016 |
| 16 | */ |
| 17 | public class WinHttpProxyInfo extends Structure { |
| 18 | |
| 19 | /** |
| 20 | * Unsigned long integer value that contains the access type. This can be |
| 21 | * one of the following values: |
| 22 | * <ul> |
| 23 | * <li>WINHTTP_ACCESS_TYPE_NO_PROXY</li> |
| 24 | * <li>WINHTTP_ACCESS_TYPE_DEFAULT_PROXY</li> |
| 25 | * <li>WINHTTP_ACCESS_TYPE_NAMED_PROXY</li> |
| 26 | * </ul> |
| 27 | */ |
| 28 | public WinDef.DWORD dwAccessType; |
| 29 | |
| 30 | /** |
| 31 | * Pointer to a string value that contains the proxy server list. |
| 32 | */ |
| 33 | public WTypes.LPWSTR lpszProxy; |
| 34 | |
| 35 | /** |
| 36 | * Pointer to a string value that contains the proxy bypass list. |
| 37 | */ |
| 38 | public WTypes.LPWSTR lpszProxyBypass; |
| 39 | |
| 40 | /** |
| 41 | * Create WinHttpProxyInfo structure. |
| 42 | */ |
| 43 | public WinHttpProxyInfo() { |
| 44 | super(); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Create WinHttpProxyInfo structure cast onto pre-allocated memory. |
| 49 | * |
| 50 | * @param pointer |
| 51 | * pointer to pre-allocated memory |
| 52 | */ |
| 53 | public WinHttpProxyInfo(Pointer pointer) { |
| 54 | super(pointer); |
| 55 | read(); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Return this Structure's field names in their proper order. For example, |
| 60 | * |
| 61 | * <pre> |
| 62 | * <code> |
| 63 | * protected List getFieldOrder() { |
| 64 | * return Arrays.asList(new String[] { ... }); |
| 65 | * } |
| 66 | * </code> |
| 67 | * </pre> |
| 68 | * |
| 69 | * <strong>IMPORTANT</strong> When deriving from an existing Structure |
| 70 | * subclass, ensure that you augment the list provided by the superclass, |
| 71 | * e.g. |
| 72 | * |
| 73 | * <pre> |
| 74 | * <code> |
| 75 | * protected List getFieldOrder() { |
| 76 | * List fields = new ArrayList(super.getFieldOrder()); |
| 77 | * fields.addAll(Arrays.asList(new String[] { ... })); |
| 78 | * return fields; |
| 79 | * } |
| 80 | * </code> |
| 81 | * </pre> |
| 82 | * |
| 83 | * Field order must be explicitly indicated, since the field order as |
| 84 | * returned by {@link Class#getFields()} is not guaranteed to be |
| 85 | * predictable. |
| 86 | * |
| 87 | * @return ordered list of field names |
| 88 | */ |
| 89 | @Override |
| 90 | protected List<String> getFieldOrder() { |
| 91 | return Arrays.asList("dwAccessType", "lpszProxy", "lpszProxyBypass"); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Tagging interface to indicate the address of an instance of the Structure |
| 96 | * type is to be used within a <code>Structure</code> definition rather than |
| 97 | * nesting the full Structure contents. The default behavior is to inline |
| 98 | * <code>Structure</code> fields. |
| 99 | */ |
| 100 | public static class ByReference extends WinHttpProxyInfo implements Structure.ByReference { |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Tagging interface to indicate the value of an instance of the |
| 105 | * <code>Structure</code> type is to be used in function invocations rather |
| 106 | * than its address. The default behavior is to treat <code>Structure</code> |
| 107 | * function parameters and return values as by reference, meaning the |
| 108 | * address of the structure is used. |
| 109 | */ |
| 110 | public static class ByValue extends WinHttpProxyInfo implements Structure.ByValue { |
| 111 | } |
| 112 | |
| 113 | } |