ardour
nag.cc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Paul Davis
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program 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
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 
18 */
19 
20 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23 
24 #include <fstream>
25 #include <gtkmm/stock.h>
26 
27 #include "pbd/openuri.h"
28 
31 
32 #include "nag.h"
33 #include "i18n.h"
34 
35 using namespace ARDOUR;
36 using namespace std;
37 using namespace Glib;
38 using namespace Gtk;
39 
40 NagScreen::NagScreen (std::string /*context*/, bool maybe_sub)
41  : ArdourDialog (string_compose (_("Support %1 Development"), PROGRAM_NAME), true)
42  , donate_button (button_group, _("I'd like to make a one-time donation"))
43  , subscribe_button (button_group, _("Tell me more about becoming a subscriber"))
44  , existing_button (button_group, _("I'm already a subscriber!"))
45  , next_time_button (button_group, _("Ask about this the next time I export"))
46  , never_again_button (button_group, _("Never ever ask me about this again"))
47 {
48  if (maybe_sub) {
49  message.set_text (_("Congratulations on your session export.\n\n\
50 It looks as if you may already be a subscriber. If so, thanks, and sorry\n\
51 to bother you again about this - I'm working on improving our subscriber system\n\
52 so that I don't have to keep annoying you with this message.\n\n\
53 If you're not a subscriber, perhaps you might consider supporting my work\n\
54 on Ardour with either a one-time donation or subscription. Nothing will \n\
55 happen if you choose not to do so. However Ardour's continuing development\n\
56 relies on a stable, sustainable income stream. Thanks for using Ardour!"));
57  } else {
58  message.set_text (_("Congratulations on your session export.\n\n\
59 I hope you find Ardour a useful tool. I'd like to ask you to consider supporting\n\
60 its development with either a one-time donation or subscription. Nothing\n\
61 will happen if you choose not to do so. However Ardour's continuing development\n\
62 relies on a stable, sustainable income stream. Thanks for using Ardour!"));
63  }
64 
65  button_box.pack_start (donate_button);
66  button_box.pack_start (subscribe_button);
67  button_box.pack_start (existing_button);
68  button_box.pack_start (next_time_button);
69  button_box.pack_start (never_again_button);
70 
71  get_vbox()->set_spacing (12);
72  get_vbox()->pack_start (message);
73  get_vbox()->pack_start (button_box);
74 
75  set_border_width (12);
76  add_button (Stock::OK, RESPONSE_ACCEPT);
77 }
78 
80 {
81 }
82 
83 void
85 {
86  show_all ();
87 
88  int response = run ();
89 
90  hide ();
91 
92  switch (response) {
93  case RESPONSE_ACCEPT:
94  break;
95  default:
96  return;
97  }
98 
99  if (donate_button.get_active()) {
100  offer_to_donate ();
101  } else if (subscribe_button.get_active()) {
103  } else if (never_again_button.get_active ()) {
104  mark_never_again ();
105  } else if (existing_button.get_active ()) {
107  }
108 }
109 
110 NagScreen*
111 NagScreen::maybe_nag (std::string why)
112 {
113  std::string path;
114  bool really_subscribed;
115  bool maybe_subscribed;
116 
117  path = Glib::build_filename (user_config_directory(), ".nevernag");
118 
119  if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
120  return 0;
121  }
122 
123  maybe_subscribed = is_subscribed (really_subscribed);
124 
125  if (really_subscribed) {
126  return 0;
127  }
128 
129  return new NagScreen (why, maybe_subscribed);
130 }
131 
132 void
134 {
135  std::string path;
136 
137  path = Glib::build_filename (user_config_directory(), ".nevernag");
138 
139  ofstream nagfile (path.c_str());
140 }
141 
142 void
144 {
145  std::string path;
146 
147  path = Glib::build_filename (user_config_directory(), ".askedaboutsub");
148 
149  ofstream subsfile (path.c_str());
150 }
151 
152 void
154 {
155  std::string path;
156 
157  path = Glib::build_filename (user_config_directory(), ".isubscribe");
158 
159  ofstream subsfile (path.c_str());
160 }
161 
162 bool
164 {
165  std::string path;
166 
167  really = false;
168 
169  /* what we'd really like here is a way to query paypal
170  for someone's subscription status. thats a bit complicated
171  so for now, just see if they ever told us they were
172  subscribed. we try to trust our users :)
173  */
174 
175  path = Glib::build_filename (user_config_directory(), ".isubscribe");
176  if (file_test (path, FILE_TEST_EXISTS)) {
177  really = true;
178  return true;
179  }
180 
181  path = Glib::build_filename (user_config_directory(), ".askedaboutsub");
182  if (file_test (path, FILE_TEST_EXISTS)) {
183  /* they never said they were subscribed but they
184  did once express an interest in it.
185  */
186  really = false;
187  return true;
188  }
189 
190  return false;
191 }
192 
193 void
195 {
196  /* we don't care if it fails */
197 
198  PBD::open_uri (Config->get_donate_url());
199 }
200 
201 void
203 {
204  const char* uri = "http://ardour.org/subscribe";
205 
206  if (PBD::open_uri (uri)) {
207  mark_subscriber ();
208  }
209 }
210 
void mark_subscriber()
Definition: nag.cc:143
void offer_to_subscribe()
Definition: nag.cc:202
~NagScreen()
Definition: nag.cc:79
Gtk::Label message
Definition: nag.h:40
Gtk::RadioButton next_time_button
Definition: nag.h:46
Gtk::RadioButton subscribe_button
Definition: nag.h:44
Definition: ardour_ui.h:130
void mark_never_again()
Definition: nag.cc:133
Gtk::RadioButton donate_button
Definition: nag.h:43
static NagScreen * maybe_nag(std::string context)
Definition: nag.cc:111
Definition: Beats.hpp:239
#define _(Text)
Definition: i18n.h:11
LIBARDOUR_API std::string user_config_directory(int version=-1)
LIBARDOUR_API RCConfiguration * Config
Definition: globals.cc:119
Definition: nag.h:29
Definition: amp.h:29
static bool is_subscribed(bool &really)
Definition: nag.cc:163
void offer_to_donate()
Definition: nag.cc:194
Gtk::VButtonBox button_box
Definition: nag.h:41
LIBPBD_API bool open_uri(const char *)
Definition: openuri.cc:41
Gtk::RadioButton never_again_button
Definition: nag.h:47
void mark_affirmed_subscriber()
Definition: nag.cc:153
NagScreen(std::string context, bool maybe_subscriber)
Definition: nag.cc:40
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:208
void nag()
Definition: nag.cc:84
Gtk::RadioButton existing_button
Definition: nag.h:45