00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "settings_stream_widget_connection.h"
00022 #define AND &&
00023 #define OR ||
00024 #define NOT !
00025 #define EQUAL ==
00026
00027 settings_stream_widget_connection::settings_stream_widget_connection(QWidget *parent)
00028 : QStackedWidget(parent)
00029 {
00030 setupUi(this);
00031
00032
00033
00034 QStringList predefinedUserAgentStrings;
00035 predefinedUserAgentStrings.append(QString("KStreamRipper"));
00036 predefinedUserAgentStrings.append(QString("Streamripper"));
00037 predefinedUserAgentStrings.append(QString("WinampMPEG/5.0"));
00038 predefinedUserAgentStrings.append(QString("Winamp/2.x"));
00039 predefinedUserAgentStrings.append(QString("FreeAmp/2.x"));
00040 predefinedUserAgentStrings.append(QString("XMMS/1.x"));
00041 predefinedUserAgentStrings.append(QString("UnknownPlayer/1.x"));
00042 predefinedUserAgentStrings.append(QString("IE 5.0"));
00043 predefinedUserAgentStrings.append(QString("iTunes/4.7 (Macintosh; N; PPC))"));
00044 predefinedUserAgentStrings.append(QString("RMA/1.0 (compatible; RealMedia))"));
00045 kcfg_advanced_userAgentString->setHistoryItems(predefinedUserAgentStrings);
00046 }
00047
00048
00049
00050 settings_stream_widget_connection::~settings_stream_widget_connection()
00051 {
00052 helper_disconnect_m_process_and_kill();
00053
00054
00055
00056 }
00057
00058 void settings_stream_widget_connection::helper_setServerUri_connectMProcess_startRecognization()
00059 {
00060 m_process.setServerUri(kcfg_serverUri->text());
00061 connect(
00062 &m_process,
00063 SIGNAL(not_running()),
00064 this,
00065 SLOT(change_empty_user_visible_widgets_to__connection_failed()));
00066 connect(&m_process,
00067 SIGNAL(streamNameChanged(void *, PropertyValue)),
00068 this,
00069 SLOT(setStreamName(void *, PropertyValue)));
00070 connect(&m_process,
00071 SIGNAL(serverNameChanged(void *, PropertyValue)),
00072 this,
00073 SLOT(setServerName(void *, PropertyValue)));
00074 connect(&m_process,
00075 SIGNAL(bitrateChanged(void *, PropertyValue)),
00076 this,
00077 SLOT(setBitrate(void *, PropertyValue)));
00078 connect(&m_process,
00079 SIGNAL(metaIntervalChanged(void *, PropertyValue)),
00080 this,
00081 SLOT(setMetaInterval(void *, PropertyValue)));
00082 m_process.startStreamripper();
00083 }
00084
00085 void settings_stream_widget_connection::helper_disconnect_m_process_and_kill()
00086 {
00087 disconnect(
00088 &m_process,
00089 SIGNAL(not_running()),
00090 this,
00091 SLOT(change_empty_user_visible_widgets_to__connection_failed()));
00092 disconnect(&m_process,
00093 SIGNAL(streamNameChanged(void *, PropertyValue)),
00094 this,
00095 SLOT(setStreamName(void *, PropertyValue)));
00096 disconnect(&m_process,
00097 SIGNAL(serverNameChanged(void *, PropertyValue)),
00098 this,
00099 SLOT(setServerName(void *, PropertyValue)));
00100 disconnect(&m_process,
00101 SIGNAL(bitrateChanged(void *, PropertyValue)),
00102 this,
00103 SLOT(setBitrate(void *, PropertyValue)));
00104 disconnect(&m_process,
00105 SIGNAL(metaIntervalChanged(void *, PropertyValue)),
00106 this,
00107 SLOT(setMetaInterval(void *, PropertyValue)));
00108 m_process.abortStreamripper();
00109 }
00110
00111 QString settings_stream_widget_connection::helper_qstring_localized__recognizing()
00112 {
00113 return i18nc("@item This is displayed in the stream settings dialog for the stream info after "
00114 "entering a new URI",
00115 "Recognizing...");
00116 }
00117
00118 void settings_stream_widget_connection::delete_old_streamInfo_and_start_recognization()
00119 {
00120 helper_disconnect_m_process_and_kill();
00121
00122
00123 kcfg_info_serverName->setText(ripping::default_value_of_serverName());
00124 kcfg_info_streamName->setText(ripping::default_value_of_streamName());
00125 kcfg_info_bitrate->setValue(ripping::default_value_of_bitrate());
00126 kcfg_info_metaInterval->setValue(ripping::default_value_of_metaInterval());
00127
00128 info_serverName->setText(helper_qstring_localized__recognizing());
00129 info_streamName->setText(helper_qstring_localized__recognizing());
00130 info_bitrate->setText(helper_qstring_localized__recognizing());
00131 info_metaInterval->setText(helper_qstring_localized__recognizing());
00132 info_serverName->setEnabled(false);
00133 info_streamName->setEnabled(false);
00134 info_bitrate->setEnabled(false);
00135 info_metaInterval->setEnabled(false);
00136
00137 helper_setServerUri_connectMProcess_startRecognization();
00138 }
00139
00140
00141
00142 void settings_stream_widget_connection::load_info_from_kcfg_and_start_recognization()
00143 {
00144 connect(kcfg_serverUri, SIGNAL(textChanged(const QString&)), this,
00145 SLOT(delete_old_streamInfo_and_start_recognization()));
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 helper_disconnect_m_process_and_kill();
00159
00160 PropertyValue temp_serverName = ripping::formatedServerName(kcfg_info_serverName->text());
00161 if (temp_serverName.type != PropertyValue::value) {
00162 temp_serverName.formatedValue = helper_qstring_localized__recognizing();
00163 };
00164 setServerName(0, temp_serverName);
00165
00166 PropertyValue temp_streamName = ripping::formatedStreamName(kcfg_info_streamName->text());
00167 if (temp_streamName.type != PropertyValue::value) {
00168 temp_streamName.formatedValue = helper_qstring_localized__recognizing();
00169 };
00170 setStreamName(0, temp_streamName);
00171
00172 PropertyValue temp_bitrate = ripping::formatedBitrate(kcfg_info_bitrate->value());
00173 if (temp_bitrate.type != PropertyValue::value) {
00174 temp_bitrate.formatedValue = helper_qstring_localized__recognizing();
00175 };
00176 setBitrate(0, temp_bitrate);
00177
00178 PropertyValue temp_metaInterval =
00179 ripping::formatedMetaInterval(kcfg_info_metaInterval->value());
00180 if (temp_metaInterval.type != PropertyValue::value) {
00181 temp_metaInterval.formatedValue = helper_qstring_localized__recognizing();
00182 };
00183 setMetaInterval(0, temp_metaInterval);
00184
00185 helper_setServerUri_connectMProcess_startRecognization();
00186 }
00187
00188 void settings_stream_widget_connection::setStreamName(void *,
00189 const PropertyValue & streamName)
00190 {
00191 kcfg_info_streamName->setText(streamName.internalValue.toString());
00192 info_streamName->setText(streamName.formatedValue);
00193 if (streamName.type == PropertyValue::value) {
00194 info_streamName->setEnabled(true);
00195 } else {
00196 info_streamName->setEnabled(false);
00197 };
00198 }
00199
00200 void settings_stream_widget_connection::setServerName(void *,
00201 const PropertyValue & serverName)
00202 {
00203 kcfg_info_serverName->setText(serverName.internalValue.toString());
00204 info_serverName->setText(serverName.formatedValue);
00205 if (serverName.type == PropertyValue::value) {
00206 info_serverName->setEnabled(true);
00207 } else {
00208 info_serverName->setEnabled(false);
00209 };
00210 }
00211
00212 void settings_stream_widget_connection::setBitrate(void *,
00213 const PropertyValue & bitrate)
00214 {
00215 kcfg_info_bitrate->setValue(bitrate.internalValue.toLongLong());
00216 info_bitrate->setText(bitrate.formatedValue);
00217 if (bitrate.type == PropertyValue::value) {
00218 info_bitrate->setEnabled(true);
00219 } else {
00220 info_bitrate->setEnabled(false);
00221 };
00222 }
00223
00224 void settings_stream_widget_connection::setMetaInterval(void *,
00225 const PropertyValue & metaInterval)
00226 {
00227 kcfg_info_metaInterval->setValue(metaInterval.internalValue.toLongLong());
00228 info_metaInterval->setText(metaInterval.formatedValue);
00229 if (metaInterval.type == PropertyValue::value) {
00230 info_metaInterval->setEnabled(true);
00231 } else {
00232 info_metaInterval->setEnabled(false);
00233 };
00234 }
00235
00236 void settings_stream_widget_connection::change_empty_user_visible_widgets_to__connection_failed()
00237 {
00238
00239 if (ripping::formatedServerName(kcfg_info_serverName->text()).type == PropertyValue::unset) {
00240 info_serverName->setText(i18nc("@item This is displayed in the stream settings dialog for "
00241 "the stream info after entering a new URI",
00242 "Connection failed."));
00243 };
00244 if (ripping::formatedServerName(kcfg_info_streamName->text()).type == PropertyValue::unset) {
00245 info_streamName->setText(i18nc("@item This is displayed in the stream settings dialog for "
00246 "the stream info after entering a new URI",
00247 "Connection failed."));
00248 };
00249 if (ripping::formatedBitrate(kcfg_info_bitrate->value()).type == PropertyValue::unset) {
00250 info_bitrate->setText(i18nc("@item This is displayed in the stream settings dialog for "
00251 "the stream info after entering a new URI",
00252 "Connection failed."));
00253 };
00254 if (ripping::formatedMetaInterval(kcfg_info_metaInterval->value()).type ==
00255 PropertyValue::unset) {
00256 info_metaInterval->setText(i18nc("@item This is displayed in the stream settings dialog for "
00257 "the stream info after entering a new URI",
00258 "Connection failed."));
00259 };
00260 }