Refreshing from server
----------------------
* Every "setup-refresh-interval" read new response from server and if 200 OK save as preference value, then reschedule next refresh

* On refresh, do GET to http://ads.[product].com/provider (e.g. http://ads.chompsms.com/provider) with the following headers:

  Accept: application/xml
  Accept-Language: en-AU (or whatever the phone is set to)
  User-Agent: whatever you have presently for sending SMS messages to smsgateway
  Accept-Encoding: gzip (this header is optional but recommended if the client can handle it)
  X-Device-Model: G1 (or whatever's appropriate, we don't use this presently but might need it later on)
  X-Accept-Providers: adsense, admob (the providers your app understands)

  The response format is below.

* Anything that's not 200 OK means the response is dumped and the phone reschedules next refresh

* If 200 OK the phone tries to parse the response. A parse error of any kind means the previous settings are used,
  and a POST is done to http://ads.[product].com/provider-error with the error details in the body (please include
  the ad setup itself if applicable).

* The default response is stored as an XML file resource

* The response from the server (if parsable) is stored as a preference

Testing providers
-----------------
The client has some way to manually trigger a refresh from the server. In that case the client uses the URL
http://ads.[product].com/provider-test (so appends '-test' to the regular URL).

Setting ad provider
-------------------
* When serving ad: read preference. If not there, or not parseable, read hard-coded ad setup and use that.

Response format
---------------

* There will only be one provider maximum

* <self-ad> is optional

* When parsing the response, ignore any elements that aren't recognised (don't error on them). If the client recognises
  an element but cannot parse the value (e.g. the color is formatted wrong), that counts as a parse error, so gets
  reported to the server as above.

  There are exceptions to this: in particular, the client should ignore the values of <selection-strategy> it doesn't
  recognise. Also, there should be at least one provider that the app recognises, or a parse error is sent to the server.

<response>

    <admob>
        <publisher-id>2309482348323</publisher-id>
        <keywords><set>phones,games</set></keywords>
        <primary-text-color>#010203</primary-text-color>
        <secondary-text-color>#010203</secondary-text-color>
        <background-color>#010203</background-color>
        <selection-strategy>last-message,keywords</selection-strategy>  <!-- One of "keywords", "last-message", or a combination separated by comma -->
        <request-interval>15</request-interval>                 <!-- seconds -->
        <setup-refresh-interval>24</setup-refresh-interval> <!-- hours -->
    </admob>

    <self-ad>
        <text>Don't wants ads, tap here to support us!</text>
    </self-ad>

</response>

<response>

    <adsense>
        <client-id>2309482348323</client-id>
        <company-name>Paradigm One Pty Ltd</company-name>
        <app-name>com.p1.chompsms</app-name>
        <channel-id>123545324</channel-id>
        <keywords><set>phones,games</set></keywords>
        <alternate-ad-url>about:blank</alternate-ad-url>
        <auto-refresh-seconds>180</auto-refresh-seconds>
        <ad-type>text</ad-type> <!-- Can be one of image, text, or text_image -->
        <alternate-color>#FFFFFF</alternate-color> <!-- Sets alternate color. When there are no targeted Google ads to show, Google displays public service ads. This method overrides this behavior to show a solid color instead.-->
        <color-background>#000000</color-background>
        <color-border>#808080</color-border>
        <color-link>#500000</color-link>
        <color-text>#808080</color-text>
        <color-url>#123456</color-url>
        <web-equivalent-url>http://www.chompsms.com</web-equivalent-url>
        <selection-strategy>last-message,keywords</selection-strategy>  <!-- One of "keywords", "last-message", or a combination separated by comma -->
        <setup-refresh-interval>24</setup-refresh-interval> <!-- hours -->
        <expandable-ad-mode>true</expandable-ad-mode>
    </adsense>

    <self-ad>
        <text>Don't wants ads, tap here to support us!</text>
    </self-ad>

</response>

