Branch data Line data Source code
1 : : /* 2 : : * Copyright (C) 2022 James Westman <james@jwestman.net> 3 : : * 4 : : * This library is free software; you can redistribute it and/or 5 : : * modify it under the terms of the GNU Lesser General Public 6 : : * License as published by the Free Software Foundation; either 7 : : * version 2.1 of the License, or (at your option) any later version. 8 : : * 9 : : * This library is distributed in the hope that it will be useful, 10 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : : * Lesser General Public License for more details. 13 : : * 14 : : * You should have received a copy of the GNU Lesser General Public 15 : : * License along with this library; if not, see <https://www.gnu.org/licenses/>. 16 : : */ 17 : : 18 : : #include <glib.h> 19 : : 20 : : #include "shumate-user-agent.h" 21 : : #include "shumate-version.h" 22 : : 23 : : 24 : : static char *user_agent = NULL; 25 : : 26 : : 27 : : /** 28 : : * shumate_get_user_agent: 29 : : * 30 : : * Gets the user agent libshumate will use for all requests. 31 : : * 32 : : * This API is not thread-safe and should only be called from the main thread. 33 : : * 34 : : * Returns: (transfer none): the user agent 35 : : */ 36 : : const char * 37 : 0 : shumate_get_user_agent (void) 38 : : { 39 [ # # ]: 0 : if (user_agent == NULL) 40 : : return "libshumate/" SHUMATE_VERSION; 41 : : else 42 : 0 : return user_agent; 43 : : } 44 : : 45 : : 46 : : /** 47 : : * shumate_set_user_agent: 48 : : * @new_user_agent: (nullable): the new user agent, or %NULL to reset to the default 49 : : * 50 : : * Sets the user agent that libshumate uses for all requests. 51 : : * 52 : : * This API is not thread-safe and should only be called from the main thread. 53 : : */ 54 : : void 55 : 0 : shumate_set_user_agent (const char *new_user_agent) 56 : : { 57 [ # # ]: 0 : g_clear_pointer (&user_agent, g_free); 58 [ # # ]: 0 : user_agent = g_strdup (new_user_agent); 59 : 0 : }