File indexing completed on 2024-04-28 16:11:02

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "accountmanager.h"
0008 #include "config-ruqola.h"
0009 #include "localdatabase/localdatabaseutils.h"
0010 #include "managerdatapaths.h"
0011 #include "notificationhistorymanager.h"
0012 #include "notifications/notifierjob.h"
0013 #include "rocketchataccount.h"
0014 #include "ruqola_debug.h"
0015 #include "ruqolaglobalconfig.h"
0016 #include <KLocalizedString>
0017 #include <QDir>
0018 #include <QDirIterator>
0019 #include <QSettings>
0020 #include <TextEmoticonsCore/EmojiModelManager>
0021 
0022 AccountManager::AccountManager(QObject *parent)
0023     : QObject(parent)
0024     , mRocketChatAccountModel(new RocketChatAccountModel(this))
0025     , mRocketChatAccountProxyModel(new RocketChatAccountFilterProxyModel(this))
0026 {
0027     mRocketChatAccountProxyModel->setSourceModel(mRocketChatAccountModel);
0028     loadExcludeEmoticons();
0029     loadAccount();
0030 }
0031 
0032 AccountManager::~AccountManager() = default;
0033 
0034 void AccountManager::loadExcludeEmoticons()
0035 {
0036 #if HAVE_TEXTADDONS_TEXTEMOTICON_EXCLUDEEMOTICON_SUPPORT
0037     const QStringList lst = QStringList({QStringLiteral(":face_holding_back_tears:"),
0038                                          QStringLiteral(":smiling_face_with_tear:"),
0039                                          QStringLiteral(":disguised_face:"),
0040                                          QStringLiteral(":face_in_clouds:"),
0041                                          QStringLiteral(":face_with_peeking_eye:"),
0042                                          QStringLiteral(":face_with_open_eyes_and_hand_over_mouth:"),
0043                                          QStringLiteral(":saluting_face:"),
0044                                          QStringLiteral(":melting_face:"),
0045                                          QStringLiteral(":dotted_line_face:"),
0046                                          QStringLiteral(":face_with_diagonal_mouth:"),
0047                                          QStringLiteral(":face_exhaling:"),
0048                                          QStringLiteral(":face_with_spiral_eyes:"),
0049                                          QStringLiteral(":heart_hands:"),
0050                                          QStringLiteral(":heart_hands_tone1:"),
0051                                          QStringLiteral(":heart_hands_tone2:"),
0052                                          QStringLiteral(":heart_hands_tone3:"),
0053                                          QStringLiteral(":heart_hands_tone4:"),
0054                                          QStringLiteral(":heart_hands_tone5:"),
0055                                          QStringLiteral(":handshake_tone1:"),
0056                                          QStringLiteral(":handshake_tone1_tone2:"),
0057                                          QStringLiteral(":handshake_tone1_tone3:"),
0058                                          QStringLiteral(":handshake_tone1_tone4:"),
0059                                          QStringLiteral(":handshake_tone1_tone5:"),
0060                                          QStringLiteral(":handshake_tone2_tone1:"),
0061                                          QStringLiteral(":handshake_tone2:"),
0062                                          QStringLiteral(":handshake_tone2_tone3:"),
0063                                          QStringLiteral(":handshake_tone2_tone4:"),
0064                                          QStringLiteral(":handshake_tone2_tone5:"),
0065                                          QStringLiteral(":handshake_tone3_tone1:"),
0066                                          QStringLiteral(":handshake_tone3_tone2:"),
0067                                          QStringLiteral(":handshake_tone3:"),
0068                                          QStringLiteral(":handshake_tone3_tone4:"),
0069                                          QStringLiteral(":handshake_tone3_tone5:"),
0070                                          QStringLiteral(":handshake_tone4_tone1:"),
0071                                          QStringLiteral(":handshake_tone4_tone2:"),
0072                                          QStringLiteral(":handshake_tone4_tone3:"),
0073                                          QStringLiteral(":handshake_tone4:"),
0074                                          QStringLiteral(":handshake_tone4_tone5:"),
0075                                          QStringLiteral(":handshake_tone5_tone1:"),
0076                                          QStringLiteral(":handshake_tone5_tone2:"),
0077                                          QStringLiteral(":handshake_tone5_tone3:"),
0078                                          QStringLiteral(":handshake_tone5_tone4:"),
0079                                          QStringLiteral(":handshake_tone5:"),
0080                                          QStringLiteral(":hand_with_index_finger_and_thumb_crossed:"),
0081                                          QStringLiteral(":hand_with_index_finger_and_thumb_crossed_tone1:"),
0082                                          QStringLiteral(":hand_with_index_finger_and_thumb_crossed_tone2:"),
0083                                          QStringLiteral(":hand_with_index_finger_and_thumb_crossed_tone3:"),
0084                                          QStringLiteral(":hand_with_index_finger_and_thumb_crossed_tone4:"),
0085                                          QStringLiteral(":hand_with_index_finger_and_thumb_crossed_tone5:"),
0086                                          QStringLiteral(":pinched_fingers:"),
0087                                          QStringLiteral(":pinched_fingers_tone2:"),
0088                                          QStringLiteral(":pinched_fingers_tone1:"),
0089                                          QStringLiteral(":pinched_fingers_tone3:"),
0090                                          QStringLiteral(":pinched_fingers_tone4:"),
0091                                          QStringLiteral(":pinched_fingers_tone5:"),
0092                                          QStringLiteral(":palm_down_hand:"),
0093                                          QStringLiteral(":palm_down_hand_tone1:"),
0094                                          QStringLiteral(":palm_down_hand_tone2:"),
0095                                          QStringLiteral(":palm_down_hand_tone3:"),
0096                                          QStringLiteral(":palm_down_hand_tone4:"),
0097                                          QStringLiteral(":palm_down_hand_tone5:"),
0098                                          QStringLiteral(":palm_up_hand:"),
0099                                          QStringLiteral(":palm_up_hand_tone1:"),
0100                                          QStringLiteral(":palm_up_hand_tone2:"),
0101                                          QStringLiteral(":palm_up_hand_tone3:"),
0102                                          QStringLiteral(":palm_up_hand_tone4:"),
0103                                          QStringLiteral(":palm_up_hand_tone5:"),
0104                                          QStringLiteral(":leftwards_hand:"),
0105                                          QStringLiteral(":leftwards_hand_tone1:"),
0106                                          QStringLiteral(":leftwards_hand_tone2:"),
0107                                          QStringLiteral(":leftwards_hand_tone3:"),
0108                                          QStringLiteral(":leftwards_hand_tone4:"),
0109                                          QStringLiteral(":leftwards_hand_tone5:"),
0110                                          QStringLiteral(":rightwards_hand:"),
0111                                          QStringLiteral(":rightwards_hand_tone1:"),
0112                                          QStringLiteral(":rightwards_hand_tone2:"),
0113                                          QStringLiteral(":rightwards_hand_tone3:"),
0114                                          QStringLiteral(":rightwards_hand_tone4:"),
0115                                          QStringLiteral(":rightwards_hand_tone5:"),
0116                                          QStringLiteral(":index_pointing_at_the_viewer:"),
0117                                          QStringLiteral(":index_pointing_at_the_viewer_tone1:"),
0118                                          QStringLiteral(":index_pointing_at_the_viewer_tone2:"),
0119                                          QStringLiteral(":index_pointing_at_the_viewer_tone3:"),
0120                                          QStringLiteral(":index_pointing_at_the_viewer_tone4:"),
0121                                          QStringLiteral(":index_pointing_at_the_viewer_tone5:"),
0122                                          QStringLiteral(":biting_lip:"),
0123                                          QStringLiteral(":anatomical_heart:"),
0124                                          QStringLiteral(":lungs:"),
0125                                          QStringLiteral(":people_hugging:"),
0126                                          QStringLiteral(":person_curly_hair:"),
0127                                          QStringLiteral(":person_tone1_curly_hair:"),
0128                                          QStringLiteral(":person_tone2_curly_hair:"),
0129                                          QStringLiteral(":person_tone3_curly_hair:"),
0130                                          QStringLiteral(":person_tone4_curly_hair:"),
0131                                          QStringLiteral(":person_tone5_curly_hair:"),
0132                                          QStringLiteral(":person_red_hair:"),
0133                                          QStringLiteral(":person_tone1_red_hair:"),
0134                                          QStringLiteral(":person_tone2_red_hair:"),
0135                                          QStringLiteral(":person_tone3_red_hair:"),
0136                                          QStringLiteral(":person_tone4_red_hair:"),
0137                                          QStringLiteral(":person_tone5_red_hair:"),
0138                                          QStringLiteral(":person_white_hair:"),
0139                                          QStringLiteral(":person_tone1_white_hair:"),
0140                                          QStringLiteral(":person_tone2_white_hair:"),
0141                                          QStringLiteral(":person_tone3_white_hair:"),
0142                                          QStringLiteral(":person_tone4_white_hair:"),
0143                                          QStringLiteral(":person_tone5_white_hair:"),
0144                                          QStringLiteral(":person_bald:"),
0145                                          QStringLiteral(":person_tone1_bald:"),
0146                                          QStringLiteral(":person_tone2_bald:"),
0147                                          QStringLiteral(":person_tone3_bald:"),
0148                                          QStringLiteral(":person_tone4_bald:"),
0149                                          QStringLiteral(":person_tone5_bald:"),
0150                                          QStringLiteral(":woman_beard:"),
0151                                          QStringLiteral(":woman_tone1_beard:"),
0152                                          QStringLiteral(":woman_tone2_beard:"),
0153                                          QStringLiteral(":woman_tone3_beard:"),
0154                                          QStringLiteral(":woman_tone4_beard:"),
0155                                          QStringLiteral(":woman_tone5_beard:"),
0156                                          QStringLiteral(":man_beard:"),
0157                                          QStringLiteral(":man_tone1_beard:"),
0158                                          QStringLiteral(":man_tone2_beard:"),
0159                                          QStringLiteral(":man_tone3_beard:"),
0160                                          QStringLiteral(":man_tone4_beard:"),
0161                                          QStringLiteral(":man_tone5_beard:"),
0162                                          QStringLiteral(":health_worker:"),
0163                                          QStringLiteral(":health_worker_tone1:"),
0164                                          QStringLiteral(":health_worker_tone2:"),
0165                                          QStringLiteral(":health_worker_tone3:"),
0166                                          QStringLiteral(":health_worker_tone4:"),
0167                                          QStringLiteral(":health_worker_tone5:"),
0168                                          QStringLiteral(":farmer:"),
0169                                          QStringLiteral(":farmer_tone1:"),
0170                                          QStringLiteral(":farmer_tone2:"),
0171                                          QStringLiteral(":farmer_tone3:"),
0172                                          QStringLiteral(":farmer_tone4:"),
0173                                          QStringLiteral(":farmer_tone5:"),
0174                                          QStringLiteral(":cook:"),
0175                                          QStringLiteral(":cook_tone1:"),
0176                                          QStringLiteral(":cook_tone2:"),
0177                                          QStringLiteral(":cook_tone3:"),
0178                                          QStringLiteral(":cook_tone4:"),
0179                                          QStringLiteral(":cook_tone5:"),
0180                                          QStringLiteral(":student:"),
0181                                          QStringLiteral(":student_tone1:"),
0182                                          QStringLiteral(":student_tone2:"),
0183                                          QStringLiteral(":student_tone3:"),
0184                                          QStringLiteral(":student_tone4:"),
0185                                          QStringLiteral(":student_tone5:"),
0186                                          QStringLiteral(":singer:"),
0187                                          QStringLiteral(":singer_tone1:"),
0188                                          QStringLiteral(":singer_tone2:"),
0189                                          QStringLiteral(":singer_tone3:"),
0190                                          QStringLiteral(":singer_tone4:"),
0191                                          QStringLiteral(":singer_tone5:"),
0192                                          QStringLiteral(":teacher:"),
0193                                          QStringLiteral(":teacher_tone1:"),
0194                                          QStringLiteral(":teacher_tone2:"),
0195                                          QStringLiteral(":teacher_tone3:"),
0196                                          QStringLiteral(":teacher_tone4:"),
0197                                          QStringLiteral(":teacher_tone5:"),
0198                                          QStringLiteral(":factory_worker:"),
0199                                          QStringLiteral(":factory_worker_tone1:"),
0200                                          QStringLiteral(":factory_worker_tone2:"),
0201                                          QStringLiteral(":factory_worker_tone3:"),
0202                                          QStringLiteral(":factory_worker_tone4:"),
0203                                          QStringLiteral(":factory_worker_tone5:"),
0204                                          QStringLiteral(":technologist:"),
0205                                          QStringLiteral(":technologist_tone1:"),
0206                                          QStringLiteral(":technologist_tone2:"),
0207                                          QStringLiteral(":technologist_tone3:"),
0208                                          QStringLiteral(":technologist_tone4:"),
0209                                          QStringLiteral(":technologist_tone5:"),
0210                                          QStringLiteral(":office_worker:"),
0211                                          QStringLiteral(":office_worker_tone1:"),
0212                                          QStringLiteral(":office_worker_tone2:"),
0213                                          QStringLiteral(":office_worker_tone3:"),
0214                                          QStringLiteral(":office_worker_tone4:"),
0215                                          QStringLiteral(":office_worker_tone5:"),
0216                                          QStringLiteral(":mechanic:"),
0217                                          QStringLiteral(":mechanic_tone1:"),
0218                                          QStringLiteral(":mechanic_tone2:"),
0219                                          QStringLiteral(":mechanic_tone3:"),
0220                                          QStringLiteral(":mechanic_tone4:"),
0221                                          QStringLiteral(":mechanic_tone5:"),
0222                                          QStringLiteral(":scientist:"),
0223                                          QStringLiteral(":scientist_tone1:"),
0224                                          QStringLiteral(":scientist_tone2:"),
0225                                          QStringLiteral(":scientist_tone3:"),
0226                                          QStringLiteral(":scientist_tone4:"),
0227                                          QStringLiteral(":scientist_tone5:"),
0228                                          QStringLiteral(":artist:"),
0229                                          QStringLiteral(":artist_tone1:"),
0230                                          QStringLiteral(":artist_tone2:"),
0231                                          QStringLiteral(":artist_tone3:"),
0232                                          QStringLiteral(":artist_tone4:"),
0233                                          QStringLiteral(":artist_tone5:"),
0234                                          QStringLiteral(":firefighter:"),
0235                                          QStringLiteral(":firefighter_tone1:"),
0236                                          QStringLiteral(":firefighter_tone2:"),
0237                                          QStringLiteral(":firefighter_tone3:"),
0238                                          QStringLiteral(":firefighter_tone4:"),
0239                                          QStringLiteral(":firefighter_tone5:"),
0240                                          QStringLiteral(":pilot:"),
0241                                          QStringLiteral(":pilot_tone1:"),
0242                                          QStringLiteral(":pilot_tone2:"),
0243                                          QStringLiteral(":pilot_tone3:"),
0244                                          QStringLiteral(":pilot_tone4:"),
0245                                          QStringLiteral(":pilot_tone5:"),
0246                                          QStringLiteral(":astronaut:"),
0247                                          QStringLiteral(":astronaut_tone1:"),
0248                                          QStringLiteral(":astronaut_tone2:"),
0249                                          QStringLiteral(":astronaut_tone3:"),
0250                                          QStringLiteral(":astronaut_tone4:"),
0251                                          QStringLiteral(":astronaut_tone5:"),
0252                                          QStringLiteral(":judge:"),
0253                                          QStringLiteral(":judge_tone1:"),
0254                                          QStringLiteral(":judge_tone2:"),
0255                                          QStringLiteral(":judge_tone3:"),
0256                                          QStringLiteral(":judge_tone4:"),
0257                                          QStringLiteral(":judge_tone5:"),
0258                                          QStringLiteral(":person_with_veil:"),
0259                                          QStringLiteral(":person_with_veil_tone1:"),
0260                                          QStringLiteral(":person_with_veil_tone2:"),
0261                                          QStringLiteral(":person_with_veil_tone3:"),
0262                                          QStringLiteral(":person_with_veil_tone4:"),
0263                                          QStringLiteral(":person_with_veil_tone5:"),
0264                                          QStringLiteral(":woman_with_veil:"),
0265                                          QStringLiteral(":woman_with_veil_tone1:"),
0266                                          QStringLiteral(":woman_with_veil_tone2:"),
0267                                          QStringLiteral(":woman_with_veil_tone3:"),
0268                                          QStringLiteral(":woman_with_veil_tone4:"),
0269                                          QStringLiteral(":woman_with_veil_tone5:"),
0270                                          QStringLiteral(":man_with_veil:"),
0271                                          QStringLiteral(":man_with_veil_tone1:"),
0272                                          QStringLiteral(":man_with_veil_tone2:"),
0273                                          QStringLiteral(":man_with_veil_tone3:"),
0274                                          QStringLiteral(":man_with_veil_tone4:"),
0275                                          QStringLiteral(":man_with_veil_tone5:"),
0276                                          QStringLiteral(":person_in_tuxedo:"),
0277                                          QStringLiteral(":person_in_tuxedo_tone1:"),
0278                                          QStringLiteral(":person_in_tuxedo_tone2:"),
0279                                          QStringLiteral(":person_in_tuxedo_tone3:"),
0280                                          QStringLiteral(":person_in_tuxedo_tone4:"),
0281                                          QStringLiteral(":person_in_tuxedo_tone5:"),
0282                                          QStringLiteral(":woman_in_tuxedo:"),
0283                                          QStringLiteral(":woman_in_tuxedo_tone1:"),
0284                                          QStringLiteral(":woman_in_tuxedo_tone2:"),
0285                                          QStringLiteral(":woman_in_tuxedo_tone3:"),
0286                                          QStringLiteral(":woman_in_tuxedo_tone4:"),
0287                                          QStringLiteral(":woman_in_tuxedo_tone5:"),
0288                                          QStringLiteral(":person_with_crown:"),
0289                                          QStringLiteral(":person_with_crown_tone1:"),
0290                                          QStringLiteral(":person_with_crown_tone2:"),
0291                                          QStringLiteral(":person_with_crown_tone3:"),
0292                                          QStringLiteral(":person_with_crown_tone4:"),
0293                                          QStringLiteral(":person_with_crown_tone5:"),
0294                                          QStringLiteral(":ninja:"),
0295                                          QStringLiteral(":ninja_tone1:"),
0296                                          QStringLiteral(":ninja_tone2:"),
0297                                          QStringLiteral(":ninja_tone3:"),
0298                                          QStringLiteral(":ninja_tone4:"),
0299                                          QStringLiteral(":ninja_tone5:"),
0300                                          QStringLiteral(":mx_claus:"),
0301                                          QStringLiteral(":mx_claus_tone1:"),
0302                                          QStringLiteral(":mx_claus_tone2:"),
0303                                          QStringLiteral(":mx_claus_tone3:"),
0304                                          QStringLiteral(":mx_claus_tone4:"),
0305                                          QStringLiteral(":mx_claus_tone5:"),
0306                                          QStringLiteral(":troll:"),
0307                                          QStringLiteral(":pregnant_person:"),
0308                                          QStringLiteral(":pregnant_person_tone1:"),
0309                                          QStringLiteral(":pregnant_person_tone2:"),
0310                                          QStringLiteral(":pregnant_person_tone3:"),
0311                                          QStringLiteral(":pregnant_person_tone4:"),
0312                                          QStringLiteral(":pregnant_person_tone5:"),
0313                                          QStringLiteral(":pregnant_man:"),
0314                                          QStringLiteral(":pregnant_man_tone1:"),
0315                                          QStringLiteral(":pregnant_man_tone2:"),
0316                                          QStringLiteral(":pregnant_man_tone3:"),
0317                                          QStringLiteral(":pregnant_man_tone4:"),
0318                                          QStringLiteral(":pregnant_man_tone5:"),
0319                                          QStringLiteral(":person_feeding_baby:"),
0320                                          QStringLiteral(":person_feeding_baby_tone1:"),
0321                                          QStringLiteral(":person_feeding_baby_tone2:"),
0322                                          QStringLiteral(":person_feeding_baby_tone3:"),
0323                                          QStringLiteral(":person_feeding_baby_tone4:"),
0324                                          QStringLiteral(":person_feeding_baby_tone5:"),
0325                                          QStringLiteral(":woman_feeding_baby:"),
0326                                          QStringLiteral(":woman_feeding_baby_tone1:"),
0327                                          QStringLiteral(":woman_feeding_baby_tone2:"),
0328                                          QStringLiteral(":woman_feeding_baby_tone3:"),
0329                                          QStringLiteral(":woman_feeding_baby_tone4:"),
0330                                          QStringLiteral(":woman_feeding_baby_tone5:"),
0331                                          QStringLiteral(":man_feeding_baby:"),
0332                                          QStringLiteral(":man_feeding_baby_tone1:"),
0333                                          QStringLiteral(":man_feeding_baby_tone2:"),
0334                                          QStringLiteral(":man_feeding_baby_tone3:"),
0335                                          QStringLiteral(":man_feeding_baby_tone4:"),
0336                                          QStringLiteral(":man_feeding_baby_tone5:"),
0337                                          QStringLiteral(":person_in_manual_wheelchair:"),
0338                                          QStringLiteral(":person_in_manual_wheelchair_tone1:"),
0339                                          QStringLiteral(":person_in_manual_wheelchair_tone2:"),
0340                                          QStringLiteral(":person_in_manual_wheelchair_tone3:"),
0341                                          QStringLiteral(":person_in_manual_wheelchair_tone4:"),
0342                                          QStringLiteral(":person_in_manual_wheelchair_tone5:"),
0343                                          QStringLiteral(":person_in_motorized_wheelchair:"),
0344                                          QStringLiteral(":person_in_motorized_wheelchair_tone1:"),
0345                                          QStringLiteral(":person_in_motorized_wheelchair_tone2:"),
0346                                          QStringLiteral(":person_in_motorized_wheelchair_tone3:"),
0347                                          QStringLiteral(":person_in_motorized_wheelchair_tone4:"),
0348                                          QStringLiteral(":person_in_motorized_wheelchair_tone5:"),
0349                                          QStringLiteral(":person_with_probing_cane:"),
0350                                          QStringLiteral(":person_with_probing_cane_tone1:"),
0351                                          QStringLiteral(":person_with_probing_cane_tone2:"),
0352                                          QStringLiteral(":person_with_probing_cane_tone3:"),
0353                                          QStringLiteral(":person_with_probing_cane_tone4:"),
0354                                          QStringLiteral(":person_with_probing_cane_tone5:"),
0355                                          QStringLiteral(":people_holding_hands_tone1_tone2:"),
0356                                          QStringLiteral(":people_holding_hands_tone1_tone3:"),
0357                                          QStringLiteral(":people_holding_hands_tone1_tone4:"),
0358                                          QStringLiteral(":people_holding_hands_tone1_tone5:"),
0359                                          QStringLiteral(":people_holding_hands_tone2_tone3:"),
0360                                          QStringLiteral(":people_holding_hands_tone2_tone4:"),
0361                                          QStringLiteral(":people_holding_hands_tone2_tone5:"),
0362                                          QStringLiteral(":people_holding_hands_tone3_tone4:"),
0363                                          QStringLiteral(":people_holding_hands_tone3_tone5:"),
0364                                          QStringLiteral(":people_holding_hands_tone4_tone5:"),
0365                                          QStringLiteral(":women_holding_hands_tone1_tone2:"),
0366                                          QStringLiteral(":women_holding_hands_tone1_tone3:"),
0367                                          QStringLiteral(":women_holding_hands_tone1_tone4:"),
0368                                          QStringLiteral(":women_holding_hands_tone1_tone5:"),
0369                                          QStringLiteral(":women_holding_hands_tone2_tone3:"),
0370                                          QStringLiteral(":women_holding_hands_tone2_tone4:"),
0371                                          QStringLiteral(":women_holding_hands_tone2_tone5:"),
0372                                          QStringLiteral(":women_holding_hands_tone3_tone4:"),
0373                                          QStringLiteral(":women_holding_hands_tone3_tone5:"),
0374                                          QStringLiteral(":women_holding_hands_tone4_tone5:"),
0375                                          QStringLiteral(":men_holding_hands_tone1_tone2:"),
0376                                          QStringLiteral(":men_holding_hands_tone1_tone3:"),
0377                                          QStringLiteral(":men_holding_hands_tone1_tone4:"),
0378                                          QStringLiteral(":men_holding_hands_tone1_tone5:"),
0379                                          QStringLiteral(":men_holding_hands_tone2_tone3:"),
0380                                          QStringLiteral(":men_holding_hands_tone2_tone4:"),
0381                                          QStringLiteral(":men_holding_hands_tone2_tone5:"),
0382                                          QStringLiteral(":men_holding_hands_tone3_tone4:"),
0383                                          QStringLiteral(":men_holding_hands_tone3_tone5:"),
0384                                          QStringLiteral(":men_holding_hands_tone4_tone5:"),
0385                                          QStringLiteral(":couple_with_heart_tone1:"),
0386                                          QStringLiteral(":couple_with_heart_person_person_tone1_tone2:"),
0387                                          QStringLiteral(":couple_with_heart_person_person_tone1_tone3:"),
0388                                          QStringLiteral(":couple_with_heart_person_person_tone1_tone4:"),
0389                                          QStringLiteral(":couple_with_heart_person_person_tone1_tone5:"),
0390                                          QStringLiteral(":couple_with_heart_person_person_tone2_tone1:"),
0391                                          QStringLiteral(":couple_with_heart_tone2:"),
0392                                          QStringLiteral(":couple_with_heart_person_person_tone2_tone3:"),
0393                                          QStringLiteral(":couple_with_heart_person_person_tone2_tone4:"),
0394                                          QStringLiteral(":couple_with_heart_person_person_tone2_tone5:"),
0395                                          QStringLiteral(":couple_with_heart_person_person_tone3_tone1:"),
0396                                          QStringLiteral(":couple_with_heart_person_person_tone3_tone2:"),
0397                                          QStringLiteral(":couple_with_heart_tone3:"),
0398                                          QStringLiteral(":couple_with_heart_person_person_tone3_tone4:"),
0399                                          QStringLiteral(":couple_with_heart_person_person_tone3_tone5:"),
0400                                          QStringLiteral(":couple_with_heart_person_person_tone4_tone1:"),
0401                                          QStringLiteral(":couple_with_heart_person_person_tone4_tone2:"),
0402                                          QStringLiteral(":couple_with_heart_person_person_tone4_tone3:"),
0403                                          QStringLiteral(":couple_with_heart_tone4:"),
0404                                          QStringLiteral(":couple_with_heart_person_person_tone4_tone5:"),
0405                                          QStringLiteral(":couple_with_heart_person_person_tone5_tone1:"),
0406                                          QStringLiteral(":couple_with_heart_person_person_tone5_tone2:"),
0407                                          QStringLiteral(":couple_with_heart_person_person_tone5_tone3:"),
0408                                          QStringLiteral(":couple_with_heart_person_person_tone5_tone4:"),
0409                                          QStringLiteral(":couple_with_heart_tone5:"),
0410                                          QStringLiteral(":couple_with_heart_woman_man_tone1:"),
0411                                          QStringLiteral(":couple_with_heart_woman_man_tone1_tone2:"),
0412                                          QStringLiteral(":couple_with_heart_woman_man_tone1_tone3:"),
0413                                          QStringLiteral(":couple_with_heart_woman_man_tone1_tone4:"),
0414                                          QStringLiteral(":couple_with_heart_woman_man_tone1_tone5:"),
0415                                          QStringLiteral(":couple_with_heart_woman_man_tone2_tone1:"),
0416                                          QStringLiteral(":couple_with_heart_woman_man_tone2:"),
0417                                          QStringLiteral(":couple_with_heart_woman_man_tone2_tone3:"),
0418                                          QStringLiteral(":couple_with_heart_woman_man_tone2_tone4:"),
0419                                          QStringLiteral(":couple_with_heart_woman_man_tone2_tone5:"),
0420                                          QStringLiteral(":couple_with_heart_woman_man_tone3_tone1:"),
0421                                          QStringLiteral(":couple_with_heart_woman_man_tone3_tone2:"),
0422                                          QStringLiteral(":couple_with_heart_woman_man_tone3:"),
0423                                          QStringLiteral(":couple_with_heart_woman_man_tone3_tone4:"),
0424                                          QStringLiteral(":couple_with_heart_woman_man_tone3_tone5:"),
0425                                          QStringLiteral(":couple_with_heart_woman_man_tone4_tone1:"),
0426                                          QStringLiteral(":couple_with_heart_woman_man_tone4_tone2:"),
0427                                          QStringLiteral(":couple_with_heart_woman_man_tone4_tone3:"),
0428                                          QStringLiteral(":couple_with_heart_woman_man_tone4:"),
0429                                          QStringLiteral(":couple_with_heart_woman_man_tone4_tone5:"),
0430                                          QStringLiteral(":couple_with_heart_woman_man_tone5_tone1:"),
0431                                          QStringLiteral(":couple_with_heart_woman_man_tone5_tone2:"),
0432                                          QStringLiteral(":couple_with_heart_woman_man_tone5_tone3:"),
0433                                          QStringLiteral(":couple_with_heart_woman_man_tone5_tone4:"),
0434                                          QStringLiteral(":couple_with_heart_woman_man_tone5:"),
0435                                          QStringLiteral(":couple_with_heart_woman_woman_tone1:"),
0436                                          QStringLiteral(":couple_with_heart_woman_woman_tone1_tone2:"),
0437                                          QStringLiteral(":couple_with_heart_woman_woman_tone1_tone3:"),
0438                                          QStringLiteral(":couple_with_heart_woman_woman_tone1_tone4:"),
0439                                          QStringLiteral(":couple_with_heart_woman_woman_tone1_tone5:"),
0440                                          QStringLiteral(":couple_with_heart_woman_woman_tone2_tone1:"),
0441                                          QStringLiteral(":couple_with_heart_woman_woman_tone2:"),
0442                                          QStringLiteral(":couple_with_heart_woman_woman_tone2_tone3:"),
0443                                          QStringLiteral(":couple_with_heart_woman_woman_tone2_tone4:"),
0444                                          QStringLiteral(":couple_with_heart_woman_woman_tone2_tone5:"),
0445                                          QStringLiteral(":couple_with_heart_woman_woman_tone3_tone1:"),
0446                                          QStringLiteral(":couple_with_heart_woman_woman_tone3_tone2:"),
0447                                          QStringLiteral(":couple_with_heart_woman_woman_tone3:"),
0448                                          QStringLiteral(":couple_with_heart_woman_woman_tone3_tone4:"),
0449                                          QStringLiteral(":couple_with_heart_woman_woman_tone3_tone5:"),
0450                                          QStringLiteral(":couple_with_heart_woman_woman_tone4_tone1:"),
0451                                          QStringLiteral(":couple_with_heart_woman_woman_tone4_tone2:"),
0452                                          QStringLiteral(":couple_with_heart_woman_woman_tone4_tone3:"),
0453                                          QStringLiteral(":couple_with_heart_woman_woman_tone4:"),
0454                                          QStringLiteral(":couple_with_heart_woman_woman_tone4_tone5:"),
0455                                          QStringLiteral(":couple_with_heart_woman_woman_tone5_tone1:"),
0456                                          QStringLiteral(":couple_with_heart_woman_woman_tone5_tone2:"),
0457                                          QStringLiteral(":couple_with_heart_woman_woman_tone5_tone3:"),
0458                                          QStringLiteral(":couple_with_heart_woman_woman_tone5_tone4:"),
0459                                          QStringLiteral(":couple_with_heart_woman_woman_tone5:"),
0460                                          QStringLiteral(":couple_with_heart_man_man_tone1:"),
0461                                          QStringLiteral(":couple_with_heart_man_man_tone1_tone2:"),
0462                                          QStringLiteral(":couple_with_heart_man_man_tone1_tone3:"),
0463                                          QStringLiteral(":couple_with_heart_man_man_tone1_tone4:"),
0464                                          QStringLiteral(":couple_with_heart_man_man_tone1_tone5:"),
0465                                          QStringLiteral(":couple_with_heart_man_man_tone2_tone1:"),
0466                                          QStringLiteral(":couple_with_heart_man_man_tone2:"),
0467                                          QStringLiteral(":couple_with_heart_man_man_tone2_tone3:"),
0468                                          QStringLiteral(":couple_with_heart_man_man_tone2_tone4:"),
0469                                          QStringLiteral(":couple_with_heart_man_man_tone2_tone5:"),
0470                                          QStringLiteral(":couple_with_heart_man_man_tone3_tone1:"),
0471                                          QStringLiteral(":couple_with_heart_man_man_tone3_tone2:"),
0472                                          QStringLiteral(":couple_with_heart_man_man_tone3:"),
0473                                          QStringLiteral(":couple_with_heart_man_man_tone3_tone4:"),
0474                                          QStringLiteral(":couple_with_heart_man_man_tone3_tone5:"),
0475                                          QStringLiteral(":couple_with_heart_man_man_tone4_tone1:"),
0476                                          QStringLiteral(":couple_with_heart_man_man_tone4_tone2:"),
0477                                          QStringLiteral(":couple_with_heart_man_man_tone4_tone3:"),
0478                                          QStringLiteral(":couple_with_heart_man_man_tone4:"),
0479                                          QStringLiteral(":couple_with_heart_man_man_tone4_tone5:"),
0480                                          QStringLiteral(":couple_with_heart_man_man_tone5_tone1:"),
0481                                          QStringLiteral(":couple_with_heart_man_man_tone5_tone2:"),
0482                                          QStringLiteral(":couple_with_heart_man_man_tone5_tone3:"),
0483                                          QStringLiteral(":couple_with_heart_man_man_tone5_tone4:"),
0484                                          QStringLiteral(":couple_with_heart_man_man_tone5:"),
0485                                          QStringLiteral(":kiss_tone1:"),
0486                                          QStringLiteral(":kiss_person_person_tone1_tone2:"),
0487                                          QStringLiteral(":kiss_person_person_tone1_tone3:"),
0488                                          QStringLiteral(":kiss_person_person_tone1_tone4:"),
0489                                          QStringLiteral(":kiss_person_person_tone1_tone5:"),
0490                                          QStringLiteral(":kiss_person_person_tone2_tone1:"),
0491                                          QStringLiteral(":kiss_tone2:"),
0492                                          QStringLiteral(":kiss_person_person_tone2_tone3:"),
0493                                          QStringLiteral(":kiss_person_person_tone2_tone4:"),
0494                                          QStringLiteral(":kiss_person_person_tone2_tone5:"),
0495                                          QStringLiteral(":kiss_person_person_tone3_tone1:"),
0496                                          QStringLiteral(":kiss_person_person_tone3_tone2:"),
0497                                          QStringLiteral(":kiss_tone3:"),
0498                                          QStringLiteral(":kiss_person_person_tone3_tone4:"),
0499                                          QStringLiteral(":kiss_person_person_tone3_tone5:"),
0500                                          QStringLiteral(":kiss_person_person_tone4_tone1:"),
0501                                          QStringLiteral(":kiss_person_person_tone4_tone2:"),
0502                                          QStringLiteral(":kiss_person_person_tone4_tone3:"),
0503                                          QStringLiteral(":kiss_tone4:"),
0504                                          QStringLiteral(":kiss_person_person_tone4_tone5:"),
0505                                          QStringLiteral(":kiss_person_person_tone5_tone1:"),
0506                                          QStringLiteral(":kiss_person_person_tone5_tone2:"),
0507                                          QStringLiteral(":kiss_person_person_tone5_tone3:"),
0508                                          QStringLiteral(":kiss_person_person_tone5_tone4:"),
0509                                          QStringLiteral(":kiss_tone5:"),
0510                                          QStringLiteral(":kiss_woman_man_tone1:"),
0511                                          QStringLiteral(":kiss_woman_man_tone1_tone2:"),
0512                                          QStringLiteral(":kiss_woman_man_tone1_tone3:"),
0513                                          QStringLiteral(":kiss_woman_man_tone1_tone4:"),
0514                                          QStringLiteral(":kiss_woman_man_tone1_tone5:"),
0515                                          QStringLiteral(":kiss_woman_man_tone2_tone1:"),
0516                                          QStringLiteral(":kiss_woman_man_tone2:"),
0517                                          QStringLiteral(":kiss_woman_man_tone2_tone3:"),
0518                                          QStringLiteral(":kiss_woman_man_tone2_tone4:"),
0519                                          QStringLiteral(":kiss_woman_man_tone2_tone5:"),
0520                                          QStringLiteral(":kiss_woman_man_tone3_tone1:"),
0521                                          QStringLiteral(":kiss_woman_man_tone3_tone2:"),
0522                                          QStringLiteral(":kiss_woman_man_tone3:"),
0523                                          QStringLiteral(":kiss_woman_man_tone3_tone4:"),
0524                                          QStringLiteral(":kiss_woman_man_tone3_tone5:"),
0525                                          QStringLiteral(":kiss_woman_man_tone4_tone1:"),
0526                                          QStringLiteral(":kiss_woman_man_tone4_tone2:"),
0527                                          QStringLiteral(":kiss_woman_man_tone4_tone3:"),
0528                                          QStringLiteral(":kiss_woman_man_tone4:"),
0529                                          QStringLiteral(":kiss_woman_man_tone4_tone5:"),
0530                                          QStringLiteral(":kiss_woman_man_tone5_tone1:"),
0531                                          QStringLiteral(":kiss_woman_man_tone5_tone2:"),
0532                                          QStringLiteral(":kiss_woman_man_tone5_tone3:"),
0533                                          QStringLiteral(":kiss_woman_man_tone5_tone4:"),
0534                                          QStringLiteral(":kiss_woman_man_tone5:"),
0535                                          QStringLiteral(":kiss_woman_woman_tone1:"),
0536                                          QStringLiteral(":kiss_woman_woman_tone1_tone2:"),
0537                                          QStringLiteral(":kiss_woman_woman_tone1_tone3:"),
0538                                          QStringLiteral(":kiss_woman_woman_tone1_tone4:"),
0539                                          QStringLiteral(":kiss_woman_woman_tone1_tone5:"),
0540                                          QStringLiteral(":kiss_woman_woman_tone2_tone1:"),
0541                                          QStringLiteral(":kiss_woman_woman_tone2:"),
0542                                          QStringLiteral(":kiss_woman_woman_tone2_tone3:"),
0543                                          QStringLiteral(":kiss_woman_woman_tone2_tone4:"),
0544                                          QStringLiteral(":kiss_woman_woman_tone2_tone5:"),
0545                                          QStringLiteral(":kiss_woman_woman_tone3_tone1:"),
0546                                          QStringLiteral(":kiss_woman_woman_tone3_tone2:"),
0547                                          QStringLiteral(":kiss_woman_woman_tone3:"),
0548                                          QStringLiteral(":kiss_woman_woman_tone3_tone4:"),
0549                                          QStringLiteral(":kiss_woman_woman_tone3_tone5:"),
0550                                          QStringLiteral(":kiss_woman_woman_tone4_tone1:"),
0551                                          QStringLiteral(":kiss_woman_woman_tone4_tone2:"),
0552                                          QStringLiteral(":kiss_woman_woman_tone4_tone3:"),
0553                                          QStringLiteral(":kiss_woman_woman_tone4:"),
0554                                          QStringLiteral(":kiss_woman_woman_tone4_tone5:"),
0555                                          QStringLiteral(":kiss_woman_woman_tone5_tone1:"),
0556                                          QStringLiteral(":kiss_woman_woman_tone5_tone2:"),
0557                                          QStringLiteral(":kiss_woman_woman_tone5_tone3:"),
0558                                          QStringLiteral(":kiss_woman_woman_tone5_tone4:"),
0559                                          QStringLiteral(":kiss_woman_woman_tone5:"),
0560                                          QStringLiteral(":kiss_man_man_tone1:"),
0561                                          QStringLiteral(":kiss_man_man_tone1_tone2:"),
0562                                          QStringLiteral(":kiss_man_man_tone1_tone3:"),
0563                                          QStringLiteral(":kiss_man_man_tone1_tone4:"),
0564                                          QStringLiteral(":kiss_man_man_tone1_tone5:"),
0565                                          QStringLiteral(":kiss_man_man_tone2_tone1:"),
0566                                          QStringLiteral(":kiss_man_man_tone2:"),
0567                                          QStringLiteral(":kiss_man_man_tone2_tone3:"),
0568                                          QStringLiteral(":kiss_man_man_tone2_tone4:"),
0569                                          QStringLiteral(":kiss_man_man_tone2_tone5:"),
0570                                          QStringLiteral(":kiss_man_man_tone3_tone1:"),
0571                                          QStringLiteral(":kiss_man_man_tone3_tone2:"),
0572                                          QStringLiteral(":kiss_man_man_tone3:"),
0573                                          QStringLiteral(":kiss_man_man_tone3_tone4:"),
0574                                          QStringLiteral(":kiss_man_man_tone3_tone5:"),
0575                                          QStringLiteral(":kiss_man_man_tone4_tone1:"),
0576                                          QStringLiteral(":kiss_man_man_tone4_tone2:"),
0577                                          QStringLiteral(":kiss_man_man_tone4_tone3:"),
0578                                          QStringLiteral(":kiss_man_man_tone4:"),
0579                                          QStringLiteral(":kiss_man_man_tone4_tone5:"),
0580                                          QStringLiteral(":kiss_man_man_tone5_tone1:"),
0581                                          QStringLiteral(":kiss_man_man_tone5_tone2:"),
0582                                          QStringLiteral(":kiss_man_man_tone5_tone3:"),
0583                                          QStringLiteral(":kiss_man_man_tone5_tone4:"),
0584                                          QStringLiteral(":kiss_man_man_tone5:"),
0585                                          QStringLiteral(":knot:"),
0586                                          QStringLiteral(":sewing_needle:"),
0587                                          QStringLiteral(":thong_sandal:"),
0588                                          QStringLiteral(":military_helmet:"),
0589                                          QStringLiteral(":polar_bear:"),
0590                                          QStringLiteral(":worm:"),
0591                                          QStringLiteral(":lady_beetle:"),
0592                                          QStringLiteral(":fly:"),
0593                                          QStringLiteral(":cockroach:"),
0594                                          QStringLiteral(":seal:"),
0595                                          QStringLiteral(":mammoth:"),
0596                                          QStringLiteral(":bison:"),
0597                                          QStringLiteral(":black_cat:"),
0598                                          QStringLiteral(":feather:"),
0599                                          QStringLiteral(":dodo:"),
0600                                          QStringLiteral(":beaver:"),
0601                                          QStringLiteral(":empty_nest:"),
0602                                          QStringLiteral(":nest_with_eggs:"),
0603                                          QStringLiteral(":coral:"),
0604                                          QStringLiteral(":rock:"),
0605                                          QStringLiteral(":wood:"),
0606                                          QStringLiteral(":potted_plant:"),
0607                                          QStringLiteral(":lotus:"),
0608                                          QStringLiteral(":bubbles:"),
0609                                          QStringLiteral(":blueberries:"),
0610                                          QStringLiteral(":olive:"),
0611                                          QStringLiteral(":bell_pepper:"),
0612                                          QStringLiteral(":flatbread:"),
0613                                          QStringLiteral(":tamale:"),
0614                                          QStringLiteral(":fondue:"),
0615                                          QStringLiteral(":jar:"),
0616                                          QStringLiteral(":beans:"),
0617                                          QStringLiteral(":pouring_liquid:"),
0618                                          QStringLiteral(":teapot:"),
0619                                          QStringLiteral(":bubble_tea:"),
0620                                          QStringLiteral(":boomerang:"),
0621                                          QStringLiteral(":playground_slide:"),
0622                                          QStringLiteral(":roller_skate:"),
0623                                          QStringLiteral(":long_drum:"),
0624                                          QStringLiteral(":accordion:"),
0625                                          QStringLiteral(":pickup_truck:"),
0626                                          QStringLiteral(":crutch:"),
0627                                          QStringLiteral(":wheel:"),
0628                                          QStringLiteral(":ring_buoy:"),
0629                                          QStringLiteral(":hook:"),
0630                                          QStringLiteral(":hut:"),
0631                                          QStringLiteral(":mobile_phone:"),
0632                                          QStringLiteral(":low_battery:"),
0633                                          QStringLiteral(":coin:"),
0634                                          QStringLiteral(":identification_card:"),
0635                                          QStringLiteral(":ladder:"),
0636                                          QStringLiteral(":screwdriver:"),
0637                                          QStringLiteral(":carpentry_saw:"),
0638                                          QStringLiteral(":mouse_trap:"),
0639                                          QStringLiteral(":headstone:"),
0640                                          QStringLiteral(":hamsa:"),
0641                                          QStringLiteral(":x_ray:"),
0642                                          QStringLiteral(":plunger:"),
0643                                          QStringLiteral(":toothbrush:"),
0644                                          QStringLiteral(":bucket:"),
0645                                          QStringLiteral(":nesting_dolls:"),
0646                                          QStringLiteral(":mirror:"),
0647                                          QStringLiteral(":window:"),
0648                                          QStringLiteral(":magic_wand:"),
0649                                          QStringLiteral(":piƱata:"),
0650                                          QStringLiteral(":mirror_ball:"),
0651                                          QStringLiteral(":placard:"),
0652                                          QStringLiteral(":mending_heart:"),
0653                                          QStringLiteral(":heart_on_fire:"),
0654                                          QStringLiteral(":elevator:"),
0655                                          QStringLiteral(":heavy_equals_sign:"),
0656                                          QStringLiteral(":transgender_symbol:"),
0657                                          QStringLiteral(":transgender_flag:"),
0658                                          QStringLiteral(":flag_bq:"),
0659                                          QStringLiteral(":flag_fk:"),
0660                                          QStringLiteral(":flag_gf:"),
0661                                          QStringLiteral(":flag_tf:"),
0662                                          QStringLiteral(":flag_gp:"),
0663                                          QStringLiteral(":flag_xk:"),
0664                                          QStringLiteral(":flag_mq:"),
0665                                          QStringLiteral(":flag_yt:"),
0666                                          QStringLiteral(":flag_nc:"),
0667                                          QStringLiteral(":flag_re:"),
0668                                          QStringLiteral(":flag_gs:"),
0669                                          QStringLiteral(":flag_bl:"),
0670                                          QStringLiteral(":flag_pm:"),
0671                                          QStringLiteral(":flag_wf:"),
0672                                          QStringLiteral(":flag_eh:"),
0673                                          QStringLiteral(":flag_ea:"),
0674                                          QStringLiteral(":flag_dg:"),
0675                                          QStringLiteral(":flag_mf:")});
0676     TextEmoticonsCore::EmojiModelManager::self()->setExcludeEmoticons(lst);
0677 #endif
0678 }
0679 
0680 int AccountManager::accountNumber() const
0681 {
0682     return mRocketChatAccountModel->accountNumber();
0683 }
0684 
0685 bool AccountManager::showMessage(const ParseMessageUrlUtils &parseUrl)
0686 {
0687     auto account = mRocketChatAccountModel->accountFromServerUrl(parseUrl.serverHost());
0688     if (account) {
0689         // const QString path{parseUrl.path()};
0690         const QString messageId = parseUrl.messageId();
0691         qCDebug(RUQOLA_LOG) << " parseUrl " << parseUrl;
0692         // https://<server url>/channel/python?msg=sn3gEQom7NcLxTg5h
0693         setCurrentAccount(account->accountName());
0694         // qDebug() << " account->accountName() : " << account->accountName();
0695         Q_EMIT mCurrentAccount->raiseWindow();
0696         Q_EMIT mCurrentAccount->selectChannelAndMessage(messageId, parseUrl.roomId(), parseUrl.roomIdType(), parseUrl.channelType());
0697         return true;
0698     }
0699     return false;
0700 }
0701 
0702 void AccountManager::openMessageUrl(const QString &messageUrl)
0703 {
0704     ParseMessageUrlUtils parseUrl;
0705     if (parseUrl.parseUrl(messageUrl)) {
0706         if (showMessage(parseUrl)) {
0707             return;
0708         }
0709     }
0710 
0711     Q_EMIT messageUrlNotFound(i18n("Server not found: %1", messageUrl));
0712     // TODO report error
0713 }
0714 
0715 void AccountManager::connectToAccount(RocketChatAccount *account)
0716 {
0717     connect(account, &RocketChatAccount::notification, this, [this, account](const NotificationInfo &info) {
0718         NotificationHistoryManager::self()->addNotification(info);
0719 
0720         switch (info.notificationType()) {
0721         case NotificationInfo::StandardMessage: {
0722             auto job = new NotifierJob;
0723             job->setInfo(info);
0724             connect(job, &NotifierJob::switchToAccountAndRoomName, this, &AccountManager::slotSwitchToAccountAndRoomName);
0725             connect(job, &NotifierJob::sendReply, this, [account](const QString &str, const QString &roomId, const QString &tmId) {
0726                 if (tmId.isEmpty()) {
0727                     account->sendMessage(roomId, str);
0728                 } else {
0729                     account->replyOnThread(roomId, tmId, str);
0730                 }
0731                 // qDebug() << " str" << str << " Room Name " << roomName;
0732             });
0733             job->start();
0734             break;
0735         }
0736         case NotificationInfo::ConferenceCall: {
0737             break;
0738         }
0739         }
0740     });
0741     connect(account, &RocketChatAccount::updateNotification, this, &AccountManager::updateNotification);
0742     connect(account, &RocketChatAccount::roomNeedAttention, this, &AccountManager::roomNeedAttention);
0743     connect(account, &RocketChatAccount::logoutDone, this, &AccountManager::logoutAccountDone);
0744 }
0745 
0746 void AccountManager::slotSwitchToAccountAndRoomName(const QString &accountName, const QString &roomName, const QString &channelType)
0747 {
0748     setCurrentAccount(accountName);
0749     QString linkRoom;
0750     if (channelType == QLatin1Char('c')) {
0751         linkRoom = QStringLiteral("ruqola:/room/%1").arg(roomName);
0752     } else {
0753         linkRoom = QStringLiteral("ruqola:/user/%1").arg(roomName);
0754     }
0755     Q_EMIT mCurrentAccount->raiseWindow();
0756     Q_EMIT mCurrentAccount->openLinkRequested(linkRoom);
0757 }
0758 
0759 void AccountManager::loadAccount()
0760 {
0761     qCDebug(RUQOLA_LOG) << " void AccountManager::loadAccount()" << ManagerDataPaths::self()->path(ManagerDataPaths::Config, QString());
0762     QDirIterator it(ManagerDataPaths::self()->path(ManagerDataPaths::Config, QString()),
0763                     QStringList() << QStringLiteral("ruqola.conf"),
0764                     QDir::AllEntries | QDir::NoSymLinks | QDir::NoDotAndDotDot,
0765                     QDirIterator::Subdirectories);
0766     QVector<RocketChatAccount *> lstAccounts;
0767     while (it.hasNext()) {
0768         const QString val = it.next();
0769         qCDebug(RUQOLA_LOG) << "Account found list.at(i)" << val;
0770         auto account = new RocketChatAccount(val);
0771         if (account->settings()->isValid()) {
0772             connectToAccount(account);
0773             lstAccounts.append(account);
0774         } else {
0775             account->deleteLater();
0776         }
0777     }
0778 
0779     // New account => empty list.
0780     if (lstAccounts.isEmpty()) {
0781         qCDebug(RUQOLA_LOG) << "Empty list. Create a default rocketchataccount";
0782         auto account = new RocketChatAccount();
0783         if (account->accountEnabled()) {
0784             connectToAccount(account);
0785         }
0786         lstAccounts.append(account);
0787     }
0788 
0789     mRocketChatAccountModel->setAccounts(lstAccounts);
0790 
0791     QSettings settings;
0792     const QString previousAccount = settings.value(QStringLiteral("currentAccount"), QString()).toString();
0793     if (previousAccount.isEmpty()) {
0794         // Use first one
0795         mCurrentAccount = mRocketChatAccountModel->account(0);
0796     } else {
0797         selectAccount(previousAccount);
0798         if (!mCurrentAccount) {
0799             // Use first one
0800             mCurrentAccount = mRocketChatAccountModel->account(0);
0801         }
0802     }
0803     mRocketChatAccountProxyModel->setAccountOrder(RuqolaGlobalConfig::self()->accountOrder());
0804 }
0805 
0806 RocketChatAccountFilterProxyModel *AccountManager::rocketChatAccountProxyModel() const
0807 {
0808     return mRocketChatAccountProxyModel;
0809 }
0810 
0811 RocketChatAccount *AccountManager::account() const
0812 {
0813     return mCurrentAccount;
0814 }
0815 
0816 void AccountManager::addAccount(const AccountManagerInfo &info)
0817 {
0818     // TODO verify if account exist or not ?
0819     auto account = new RocketChatAccount();
0820     account->setAccountName(info.accountName);
0821     account->setUserName(info.userName);
0822     account->setServerUrl(info.serverUrl);
0823     account->setAccountEnabled(info.enabled);
0824     account->setPassword(info.password);
0825     if (info.enabled) {
0826         connectToAccount(account);
0827     }
0828     addAccount(account);
0829 }
0830 
0831 void AccountManager::modifyAccount(const AccountManagerInfo &info)
0832 {
0833     RocketChatAccount *account = mRocketChatAccountModel->account(info.accountName);
0834     if (account) {
0835         account->setDisplayName(info.displayName);
0836         account->setUserName(info.userName);
0837         account->setServerUrl(info.serverUrl);
0838         account->setAccountEnabled(info.enabled);
0839         if (!info.enabled) {
0840             // TODO fixme
0841             // disconnect(account, &RocketChatAccount::notification, this, &AccountManager::notification);
0842             disconnect(account, &RocketChatAccount::updateNotification, this, &AccountManager::updateNotification);
0843             disconnect(account, &RocketChatAccount::logoutDone, this, &AccountManager::logoutAccountDone);
0844         }
0845     }
0846 }
0847 
0848 RocketChatAccount *AccountManager::accountFromName(const QString &accountName)
0849 {
0850     return mRocketChatAccountModel->account(accountName);
0851 }
0852 
0853 QStringList AccountManager::accountsName() const
0854 {
0855     return mRocketChatAccountModel->accountsName();
0856 }
0857 
0858 void AccountManager::addAccount(RocketChatAccount *account)
0859 {
0860     mRocketChatAccountModel->insertAccount(account);
0861 }
0862 
0863 void AccountManager::selectAccount(const QString &accountName)
0864 {
0865     RocketChatAccount *account = mRocketChatAccountModel->account(accountName);
0866     if (account) {
0867         mCurrentAccount = account;
0868     } else {
0869         qCWarning(RUQOLA_LOG) << "AccountName " << accountName << " is not found on system.";
0870     }
0871 }
0872 
0873 void AccountManager::setCurrentAccount(const QString &accountName)
0874 {
0875     RocketChatAccount *account = mRocketChatAccountModel->account(accountName);
0876     if (account) {
0877         if (mCurrentAccount != account) {
0878             QSettings settings;
0879             settings.setValue(QStringLiteral("currentAccount"), accountName);
0880             settings.sync();
0881             mCurrentAccount = account;
0882             Q_EMIT currentAccountChanged();
0883         }
0884     } else {
0885         qCWarning(RUQOLA_LOG) << "AccountName " << accountName << " is not found on system. Fallback to default one.";
0886     }
0887 }
0888 
0889 QString AccountManager::currentAccount() const
0890 {
0891     return mCurrentAccount ? mCurrentAccount->accountName() : QString();
0892 }
0893 
0894 void AccountManager::removeLogs(const QString &accountName)
0895 {
0896     const QString directory = LocalDatabaseUtils::localMessageLoggerPath() + accountName;
0897     removeDirectory(directory);
0898 }
0899 
0900 void AccountManager::removeDatabaseAccount(const QString &accountName)
0901 {
0902     const QString directory = LocalDatabaseUtils::localAccountDatabasePath() + accountName;
0903     removeDirectory(directory);
0904 }
0905 
0906 void AccountManager::removeDirectory(const QString &directory)
0907 {
0908     QDir dir(directory);
0909     if (dir.exists()) {
0910         if (!dir.removeRecursively()) {
0911             qCWarning(RUQOLA_LOG) << " Impossible to remove directory : " << directory;
0912         }
0913     }
0914 }
0915 
0916 void AccountManager::removeAccount(const QString &accountName, bool removeLogFiles)
0917 {
0918     auto account = mRocketChatAccountModel->removeAccount(accountName);
0919     if (mRocketChatAccountModel->accountNumber() > 0) {
0920         mCurrentAccount = mRocketChatAccountModel->account(0);
0921         removeDatabaseAccount(accountName);
0922         // TODO remove others files
0923         if (removeLogFiles) {
0924             removeLogs(accountName);
0925         }
0926     } else {
0927         // TODO create new dummy account !
0928     }
0929     Q_EMIT currentAccountChanged();
0930     if (account) {
0931         account->deleteLater();
0932     }
0933 }
0934 
0935 RocketChatAccountModel *AccountManager::rocketChatAccountModel() const
0936 {
0937     return mRocketChatAccountModel;
0938 }
0939 
0940 QStringList AccountManager::accountNamesSorted() const
0941 {
0942     QStringList lst;
0943     auto model = rocketChatAccountProxyModel();
0944     for (int i = 0; i < model->rowCount(); ++i) {
0945         const auto index = model->index(i, 0);
0946         auto account = index.data(RocketChatAccountModel::Account).value<RocketChatAccount *>();
0947         lst << account->displayName();
0948     }
0949     return lst;
0950 }
0951 
0952 #include "moc_accountmanager.cpp"