~bibledit/bibledit/ubuntu-cloud-beta

« back to all changes in this revision

Viewing changes to client/logic.cpp

  • Committer: Teus Benschop
  • Date: 2022-10-14 16:03:26 UTC
  • Revision ID: teusjannette@gmail.com-20221014160326-42ybrpft4bblpruk
new upstream version

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
// $address is the website.
56
56
// $port is the port number.
57
57
// $path is the path after the website.
58
 
string client_logic_url (string address, int port, string path)
 
58
string client_logic_url (const string & address, int port, const string & path)
59
59
{
60
60
  return address + ":" + convert_to_string (port) + "/" + path;
61
61
}
67
67
// It returns an empty string in case of failure or the response from the server.
68
68
string client_logic_connection_setup (string user, string hash)
69
69
{
70
 
  Database_Users database_users;
 
70
  Database_Users database_users {};
71
71
  
72
72
  if (user.empty ()) {
73
73
    vector <string> users = database_users.get_users ();
74
 
    if (users.empty()) return "";
 
74
    if (users.empty()) return string();
75
75
    user = users [0];
76
76
    hash = database_users.get_md5 (user);
77
77
  }
83
83
  
84
84
  string url = client_logic_url (address, port, sync_setup_url ()) + "?user=" + encoded_user + "&pass=" + hash;
85
85
  
86
 
  string error;
 
86
  string error {};
87
87
  string response = filter_url_http_get (url, error, true);
88
88
  int iresponse = convert_to_int (response);
89
89
  
103
103
}
104
104
 
105
105
 
106
 
string client_logic_create_note_encode (string bible, int book, int chapter, int verse,
107
 
                                        string summary, string contents, bool raw)
 
106
string client_logic_create_note_encode (const string & bible, int book, int chapter, int verse,
 
107
                                        const string & summary, const string & contents, bool raw)
108
108
{
109
 
  vector <string> data;
 
109
  vector <string> data {};
110
110
  data.push_back (bible);
111
111
  data.push_back (convert_to_string (book));
112
112
  data.push_back (convert_to_string (chapter));
118
118
}
119
119
 
120
120
 
121
 
void client_logic_create_note_decode (string data,
 
121
void client_logic_create_note_decode (const string & data,
122
122
                                      string& bible, int& book, int& chapter, int& verse,
123
123
                                      string& summary, string& contents, bool& raw)
124
124
{
155
155
// It displays the $linktext.
156
156
string client_logic_link_to_cloud (string path, string linktext)
157
157
{
158
 
  string url;
159
 
  string external;
 
158
  string url {};
 
159
  string external {};
160
160
  if (client_logic_client_enabled ()) {
161
161
    string address = Database_Config_General::getServerAddress ();
162
162
    int port = Database_Config_General::getServerPort ();
180
180
    linktext = url;
181
181
  }
182
182
  
183
 
  stringstream link;
 
183
  stringstream link {};
184
184
  link << "<a href=" << quoted(url) << external << ">" << linktext << "</a>";
185
185
  return link.str();
186
186
}
199
199
  // It is stored in the client files area.
200
200
  // Clients can access it from there.
201
201
  string path = client_logic_usfm_resources_path ();
202
 
  Database_UsfmResources database_usfmresources;
 
202
  Database_UsfmResources database_usfmresources {};
203
203
  vector <string> resources = database_usfmresources.getResources ();
204
204
  filter_url_file_put_contents (path, filter_string_implode (resources, "\n"));
205
205
}