grim/purple-spasm
Clone
Summary
Browse
Changes
Graph
Some quick memory hacks
2017-05-09, Gary Kramlich
c81e3dbaad99
Some quick memory hacks
/*
* PurpleSpasm - A Twitch Protocol Plugin
* Copyright (C) 2017 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
"spasm-account.h"
struct
_PurpleSpasmAccount
{
PurpleAccount
*
account
;
PurpleConnection
*
connection
;
SoupSession
*
session
;
gchar
*
access_token
;
};
/******************************************************************************
* API
*****************************************************************************/
PurpleSpasmAccount
*
purple_spasm_account_new
(
PurpleAccount
*
account
,
PurpleConnection
*
connection
)
{
PurpleSpasmAccount
*
sa
=
NULL
;
sa
=
g_new0
(
PurpleSpasmAccount
,
1
);
sa
->
account
=
account
;
sa
->
connection
=
connection
;
sa
->
session
=
soup_session_new
();
SoupLogger
*
logger
=
soup_logger_new
(
SOUP_LOGGER_LOG_BODY
,
-1
);
soup_session_add_feature
(
sa
->
session
,
SOUP_SESSION_FEATURE
(
logger
));
return
sa
;
}
void
purple_spasm_account_free
(
PurpleSpasmAccount
*
sa
)
{
g_return_if_fail
(
sa
);
g_free
(
sa
->
access_token
);
g_object_unref
(
G_OBJECT
(
sa
->
session
));
g_free
(
sa
);
}
PurpleAccount
*
purple_spasm_account_get_account
(
const
PurpleSpasmAccount
*
sa
)
{
g_return_val_if_fail
(
sa
,
NULL
);
return
sa
->
account
;
}
PurpleConnection
*
purple_spasm_account_get_connection
(
const
PurpleSpasmAccount
*
sa
)
{
g_return_val_if_fail
(
sa
,
NULL
);
return
sa
->
connection
;
}
SoupSession
*
purple_spasm_account_get_session
(
const
PurpleSpasmAccount
*
sa
)
{
g_return_val_if_fail
(
sa
,
NULL
);
if
(
sa
->
session
)
{
return
g_object_ref
(
G_OBJECT
(
sa
->
session
));
}
return
NULL
;
}
void
purple_spasm_account_set_access_token
(
PurpleSpasmAccount
*
sa
,
const
gchar
*
access_token
)
{
g_return_if_fail
(
sa
);
sa
->
access_token
=
g_strdup
(
access_token
);
}
const
gchar
*
purple_spasm_account_get_access_token
(
const
PurpleSpasmAccount
*
sa
)
{
g_return_val_if_fail
(
sa
,
NULL
);
return
sa
->
access_token
;
}