Skip to content

Commit

Permalink
Replace send_message calls with send_and_read from libsoup3
Browse files Browse the repository at this point in the history
  • Loading branch information
dar5hak committed Sep 28, 2024
1 parent 6fe3554 commit 488e38a
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 29 deletions.
6 changes: 3 additions & 3 deletions plugins/backend/bazqux/bazquxConnection.vala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class FeedReader.bazquxConnection {
var message = new Soup.Message("POST", "https://bazqux.com/accounts/ClientLogin/");
string message_string = "Email=" + m_username + "&Passwd=" + m_passwd;
message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data);
m_session.send_message(message);
m_session.send_and_read(message);
string response = (string)message.response_body.flatten().data;
try{

Expand Down Expand Up @@ -100,7 +100,7 @@ public class FeedReader.bazquxConnection {
message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data);
}

m_session.send_message(message);
m_session.send_and_read(message);

return Response() {
status = message.status_code,
Expand All @@ -114,7 +114,7 @@ public class FeedReader.bazquxConnection {

string oldauth = "GoogleLogin auth=" + m_utils.getAccessToken();
message.request_headers.append("Authorization", oldauth);
m_session.send_message(message);
m_session.send_and_read(message);

if((string)message.response_body.data == "OK")
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/backend/feedbin/feedbinAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class FeedbinAPI : Object {
message.request_body.append_take(input.data);
}

m_session.send_message(message);
m_session.send_and_read(message);
var status = message.status_code;
if(status < 200 || status >= 400)
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/backend/feedhq/feedhqConnection.vala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class FeedReader.FeedHQConnection {
var message = new Soup.Message("POST", "https://feedhq.org/accounts/ClientLogin");
string message_string = "Email=" + m_username + "&Passwd=" + m_passwd;
message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data);
m_session.send_message(message);
m_session.send_and_read(message);
string response = (string)message.response_body.flatten().data;
try{

Expand Down Expand Up @@ -85,7 +85,7 @@ public class FeedReader.FeedHQConnection {

string oldauth = "GoogleLogin auth=" + m_utils.getAccessToken();
message.request_headers.append("Authorization", oldauth);
m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down Expand Up @@ -124,7 +124,7 @@ public class FeedReader.FeedHQConnection {
message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string_post.data);
}

m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/backend/fresh/freshConnection.vala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class FeedReader.freshConnection {
msg.add("Passwd", m_utils.getPasswd());

message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, msg.get().data);
m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down Expand Up @@ -92,7 +92,7 @@ public class FeedReader.freshConnection {
message.request_headers.append("Content-Type", type);

message.request_body.append_take(input.data);
m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand All @@ -115,7 +115,7 @@ public class FeedReader.freshConnection {
message.request_headers.append("DNT", "1");
}

m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down
6 changes: 3 additions & 3 deletions plugins/backend/inoreader/InoReaderConnection.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FeedReader.InoReaderConnection {
+ "&scope="
+ "&grant_type=authorization_code";
message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data);
m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down Expand Up @@ -90,7 +90,7 @@ public class FeedReader.InoReaderConnection {
+ "&refresh_token=" + m_utils.getRefreshToken();

message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data);
m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down Expand Up @@ -156,7 +156,7 @@ public class FeedReader.InoReaderConnection {
message.set_request("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, message_string.data);
}

m_session.send_message(message);
m_session.send_and_read(message);

if(message.status_code != 200)
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/backend/local/localInterface.vala
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ public class FeedReader.localInterface : FeedServerInterface {
var session = new Soup.Session();
session.user_agent = Constants.USER_AGENT;
session.timeout = 5;
session.send_message(msg);
session.send_and_read(msg);
string xml = (string)msg.response_body.flatten().data;

// parse
Expand Down
4 changes: 3 additions & 1 deletion plugins/backend/local/localUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public class FeedReader.localUtils : GLib.Object {
return null;
}

uint status = session.send_message(msg);
session.send_and_read(msg);
uint status = msg.status_code;

if(status < 100 || status >= 400)
{
if(status < 100)
Expand Down
3 changes: 2 additions & 1 deletion plugins/backend/owncloud/OwncloudNewsMessage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public class FeedReader.OwnCloudNewsMessage : GLib.Object {
m_message_soup.request_headers.append("DNT", "1");
}

var status = m_session.send_message(m_message_soup);
m_session.send_and_read(m_message_soup);
var status = m_message_soup.status_code;

if(status == 401) // unauthorized

Expand Down
3 changes: 2 additions & 1 deletion plugins/backend/ttrss/ttrssMessage.vala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public class FeedReader.ttrssMessage : GLib.Object {
m_message_soup.request_headers.append("DNT", "1");
}

var status_code = m_session.send_message(m_message_soup);
m_session.send_and_read(m_message_soup);
var status_code = m_message_soup.status_code;

if(status_code == 401) // unauthorized

Expand Down
2 changes: 1 addition & 1 deletion plugins/share/Instapaper/InstapaperAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public class FeedReader.InstaAPI : ShareAccountInterface, Peas.ExtensionBase {
message_soup.request_headers.append("DNT", "1");
}

session.send_message(message_soup);
session.send_and_read(message_soup);
string response = (string)message_soup.response_body.flatten().data;

if(response == null || response == "")
Expand Down
6 changes: 3 additions & 3 deletions plugins/share/Pocket/PocketAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase {
message_soup.request_headers.append("DNT", "1");
}

session.send_message(message_soup);
session.send_and_read(message_soup);

string response = (string)message_soup.response_body.flatten().data;
return response.substring(response.index_of_char('=')+1);
Expand All @@ -98,7 +98,7 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase {
message_soup.request_headers.append("DNT", "1");
}

session.send_message(message_soup);
session.send_and_read(message_soup);

if((string)message_soup.response_body.flatten().data == null
|| (string)message_soup.response_body.flatten().data == "")
Expand Down Expand Up @@ -183,7 +183,7 @@ public class FeedReader.PocketAPI : ShareAccountInterface, Peas.ExtensionBase {
message_soup.request_headers.append("DNT", "1");
}

session.send_message(message_soup);
session.send_and_read(message_soup);

if((string)message_soup.response_body.flatten().data == null
|| (string)message_soup.response_body.flatten().data == "")
Expand Down
4 changes: 2 additions & 2 deletions plugins/share/Wallabag/WallabagAPI.vala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase
string url = baseURL + "oauth/v2/token";
var message_soup = new Soup.Message("POST", url);
message_soup.set_request("application/x-www-form-urlencoded; charset=UTF8", Soup.MemoryUse.COPY, message.data);
session.send_message(message_soup);
session.send_and_read(message_soup);

if((string)message_soup.response_body.flatten().data == null
|| (string)message_soup.response_body.flatten().data == "")
Expand Down Expand Up @@ -154,7 +154,7 @@ public class FeedReader.WallabagAPI : ShareAccountInterface, Peas.ExtensionBase
var message_soup = new Soup.Message("POST", baseURL + "api/entries.json");
message_soup.set_request("application/x-www-form-urlencoded; charset=UTF8", Soup.MemoryUse.COPY, message.data);
message_soup.request_headers.append("Authorization", "Bearer " + settings.get_string("oauth-access-token"));
session.send_message(message_soup);
session.send_and_read(message_soup);

if((string)message_soup.response_body.flatten().data == null
|| (string)message_soup.response_body.flatten().data == "")
Expand Down
4 changes: 2 additions & 2 deletions src/ContentGrabber/grabber.vala
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public class FeedReader.Grabber : GLib.Object {
return false;
}

m_session.send_message(message);
m_session.send_and_read(message);
var params = new GLib.HashTable<string, string>(null, null);
string? contentType = message.response_headers.get_content_type(out params);
if(contentType != null)
Expand Down Expand Up @@ -245,7 +245,7 @@ public class FeedReader.Grabber : GLib.Object {
msg.request_headers.append("DNT", "1");
}

m_session.send_message(msg);
m_session.send_and_read(msg);
msg.disconnect(handlerID);

if(msg.response_body == null)
Expand Down
8 changes: 5 additions & 3 deletions src/ContentGrabber/grabberUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,9 @@ public class FeedReader.grabberUtils : GLib.Object {
message_dlImg.request_headers.append("DNT", "1");
}

var status = session.send_message(message_dlImg);
session.send_and_read(message_dlImg);
var status = message_dlImg.status_code;

if(status == 200)
{
var params = new GLib.HashTable<string, string>(null, null);
Expand Down Expand Up @@ -772,7 +774,7 @@ public class FeedReader.grabberUtils : GLib.Object {
{
return null;
}
session.send_message(message);
session.send_and_read(message);
var params = new GLib.HashTable<string, string>(null, null);
string? contentType = message.response_headers.get_content_type(out params);
size = message.response_headers.get_content_length();
Expand All @@ -781,7 +783,7 @@ public class FeedReader.grabberUtils : GLib.Object {
{
return null;
}
session.send_message(message2);
session.send_and_read(message2);
origSize = message2.response_headers.get_content_length();
if(contentType != null)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ public class FeedReader.Utils : GLib.Object {
return false;
}

var status = getSession().send_message(message);
getSession().send_and_read(message);
var status = message.status_code;

Logger.debug(@"Ping: status $status");

Expand Down

0 comments on commit 488e38a

Please sign in to comment.