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("KRadioRipper"));
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(qlonglong, PropertyValue)),
00068 this,
00069 SLOT(setStreamName(qlonglong, PropertyValue)));
00070 connect(&m_process,
00071 SIGNAL(serverNameChanged(qlonglong, PropertyValue)),
00072 this,
00073 SLOT(setServerName(qlonglong, PropertyValue)));
00074 connect(&m_process,
00075 SIGNAL(bitrateChanged(qlonglong, PropertyValue)),
00076 this,
00077 SLOT(setBitrate(qlonglong, PropertyValue)));
00078 connect(&m_process,
00079 SIGNAL(metaIntervalChanged(qlonglong, PropertyValue)),
00080 this,
00081 SLOT(setMetaInterval(qlonglong, 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(qlonglong, PropertyValue)),
00094 this,
00095 SLOT(setStreamName(qlonglong, PropertyValue)));
00096 disconnect(&m_process,
00097 SIGNAL(serverNameChanged(qlonglong, PropertyValue)),
00098 this,
00099 SLOT(setServerName(qlonglong, PropertyValue)));
00100 disconnect(&m_process,
00101 SIGNAL(bitrateChanged(qlonglong, PropertyValue)),
00102 this,
00103 SLOT(setBitrate(qlonglong, PropertyValue)));
00104 disconnect(&m_process,
00105 SIGNAL(metaIntervalChanged(qlonglong, PropertyValue)),
00106 this,
00107 SLOT(setMetaInterval(qlonglong, 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(qlonglong index, PropertyValue streamName)
00189 {
00190 kcfg_info_streamName->setText(streamName.internalValue.toString());
00191 info_streamName->setText(streamName.formatedValue);
00192 if (streamName.type == PropertyValue::value) {
00193 info_streamName->setEnabled(true);
00194 } else {
00195 info_streamName->setEnabled(false);
00196 };
00197 }
00198
00199 void settings_stream_widget_connection::setServerName(qlonglong index, PropertyValue serverName)
00200 {
00201 kcfg_info_serverName->setText(serverName.internalValue.toString());
00202 info_serverName->setText(serverName.formatedValue);
00203 if (serverName.type == PropertyValue::value) {
00204 info_serverName->setEnabled(true);
00205 } else {
00206 info_serverName->setEnabled(false);
00207 };
00208 }
00209
00210 void settings_stream_widget_connection::setBitrate(qlonglong index, PropertyValue bitrate)
00211 {
00212 kcfg_info_bitrate->setValue(bitrate.internalValue.toLongLong());
00213 info_bitrate->setText(bitrate.formatedValue);
00214 if (bitrate.type == PropertyValue::value) {
00215 info_bitrate->setEnabled(true);
00216 } else {
00217 info_bitrate->setEnabled(false);
00218 };
00219 }
00220
00221 void settings_stream_widget_connection::setMetaInterval(qlonglong index,
00222 PropertyValue metaInterval)
00223 {
00224 kcfg_info_metaInterval->setValue(metaInterval.internalValue.toLongLong());
00225 info_metaInterval->setText(metaInterval.formatedValue);
00226 if (metaInterval.type == PropertyValue::value) {
00227 info_metaInterval->setEnabled(true);
00228 } else {
00229 info_metaInterval->setEnabled(false);
00230 };
00231 }
00232
00233 void settings_stream_widget_connection::change_empty_user_visible_widgets_to__connection_failed()
00234 {
00235
00236 if (ripping::formatedServerName(kcfg_info_serverName->text()).type == PropertyValue::unset) {
00237 info_serverName->setText(i18nc("@item This is displayed in the stream settings dialog for "
00238 "the stream info after entering a new URI",
00239 "Connection failed."));
00240 };
00241 if (ripping::formatedServerName(kcfg_info_streamName->text()).type == PropertyValue::unset) {
00242 info_streamName->setText(i18nc("@item This is displayed in the stream settings dialog for "
00243 "the stream info after entering a new URI",
00244 "Connection failed."));
00245 };
00246 if (ripping::formatedBitrate(kcfg_info_bitrate->value()).type == PropertyValue::unset) {
00247 info_bitrate->setText(i18nc("@item This is displayed in the stream settings dialog for "
00248 "the stream info after entering a new URI",
00249 "Connection failed."));
00250 };
00251 if (ripping::formatedMetaInterval(kcfg_info_metaInterval->value()).type ==
00252 PropertyValue::unset) {
00253 info_metaInterval->setText(i18nc("@item This is displayed in the stream settings dialog for "
00254 "the stream info after entering a new URI",
00255 "Connection failed."));
00256 };
00257 }