Logo Search packages:      
Sourcecode: nateon version File versions  Download package

void KNateon::slotViewAMemoPopup ( const MimeMessage sMemo  )  [private, slot]

쪽지 받음 소리

0 :쪽지창 바로 보여주기, 1 : 팝업창으로 알려주기

받는 사람이 본인이면,

받은 사람이 목록에 없는경우.

받는 사람이 본인이면,

받은 사람이 목록에 없는경우.

직접 쪽지 창 띄워서 보여주기

뒤의 "0", "1" 은 안읽음 필드

토스트 창으로 알려주기

0: Online, 1: incoming chat, 2: incoming memo

뒤의 "0", "1" 은 안읽음 필드

saveMemoInbox( from, ref, body, is unread? ) 온라인 쪽지에서는 unread가 0 이다.

Definition at line 1296 of file knateon.cpp.

References nmconfig::allowonlyfriendmemo, Common::fixOutString(), MimeMessage::getBody(), BuddyList::getBuddyByID(), CurrentAccount::getBuddyList(), CurrentAccount::getMyCyworldID(), CurrentAccount::getMyName(), CurrentAccount::getMyNateID(), BuddyBase::getName(), SQLiteDB::getNewMemoCount(), BuddyBase::getNick(), MimeMessage::getValue(), nmconfig::logintype, nmconfig::memorecievesoundpath, Common::percent2HTML(), pSQLiteDB, nmconfig::receivenewmemo, SQLiteDB::saveMemoInbox(), MemoPopupView::setBody(), MemoPopupView::setDate(), MemoPopupView::setReceiver(), MemoPopupView::setSender(), MemoPopupView::setTitle(), MemoPopupView::setUUID(), slotDeleteMemo(), slotPopupMemoFromUUID(), slotReplyMemo(), KNateonMainview::slotUpdateMemoCount(), sPicsPath, nmconfig::usememorecievesound, and nmconfig::usesound.

Referenced by connected().

{
      QString sBody( sMemo.getBody() );
#if 0
      if ( !m_pCommon )
            m_pCommon = new Common();
      
      m_pCommon->percent2HTML( sBody );
#endif
      m_pBuddyList = m_pCurrentAccount->getBuddyList();
      
      if ( stConfig.allowonlyfriendmemo )
      {
            Buddy *pBuddy = m_pBuddyList->getBuddyByID( sMemo.getValue("from") );
            if ( !pBuddy )
            {
#ifdef NETDEBUG
                  kdDebug() << "비버디 대화자가 메시지를 보내서 차단되었습니다. ID:[" << sMemo.getValue("from") << "]" << endl;
#endif
                  return;
            }
      }
      
      /*!
       * 쪽지 받음 소리
       */
      if ( stConfig.usesound && stConfig.usememorecievesound )
            Sound::play( stConfig.memorecievesoundpath );
      
      /*! 0 :쪽지창 바로 보여주기, 1 : 팝업창으로 알려주기 */
      if ( stConfig.receivenewmemo == 0 )
      {
            QStringList slSend = QStringList::split(";", sMemo.getValue("from") );
            QString sSender;
            for ( QStringList::Iterator it = slSend.begin(); it != slSend.end(); ++it )
            {
                  Buddy* pBuddy = m_pBuddyList->getBuddyByID(*it);
                  if (pBuddy)
                  {
                        if ( sSender.length() > 1 )
                              sSender += ";\"" + pBuddy->getName() + "\" <" + *it + ">";
                        else
                              sSender = "\"" + pBuddy->getName() + "\" <" + *it + ">";
                  }
            }
            
            QStringList slRecv = QStringList::split(";", sMemo.getValue("ref") );
            QString sReceiver;
            for ( QStringList::Iterator it = slRecv.begin(); it != slRecv.end(); ++it )
            {
                  
                  Buddy* pBuddy = m_pBuddyList->getBuddyByID(*it);
                  if ( pBuddy )
                  {
                        if ( sReceiver.length() > 1 )
                              sReceiver += ";\"" + pBuddy->getName() + "\" <" + *it + ">";
                        else
                              sReceiver = "\"" + pBuddy->getName() + "\" <" + *it + ">";
                  }
                  else
                  {
                        if ( stConfig.logintype == 'N' )
                        {
                              /// 받는 사람이 본인이면,
                              if ( *it == m_pCurrentAccount->getMyNateID() )
                              {
                                    if ( sReceiver.length() > 1 )
                                          sReceiver += ";\"" + m_pCurrentAccount->getMyName() + "\" <" + *it + ">";
                                    else
                                          sReceiver = "\"" + m_pCurrentAccount->getMyName() + "\" <" + *it + ">";
                              }
                              else /// 받은 사람이 목록에 없는경우.
                              {
                                    if ( sReceiver.length() > 1 )
                                          sReceiver += ";" + *it;
                                    else
                                          sReceiver = *it;
                              }
                        }
                        else
                        {
                              /// 받는 사람이 본인이면,
                              if ( *it == m_pCurrentAccount->getMyCyworldID() )
                              {
                                    if ( sReceiver.length() > 1 )
                                          sReceiver += ";\"" + m_pCurrentAccount->getMyName() + "\" <" + *it + ">";
                                    else
                                          sReceiver = "\"" + m_pCurrentAccount->getMyName() + "\" <" + *it + ">";
                              }
                              else /// 받은 사람이 목록에 없는경우.
                              {
                                    if ( sReceiver.length() > 1 )
                                          sReceiver += ";" + *it;
                                    else
                                          sReceiver = *it;
                              }
                        }
                  }
            }
            
            /*! 직접 쪽지 창 띄워서 보여주기 */
            MemoPopupView     *pMemo1 = new MemoPopupView();
            connect(pMemo1, SIGNAL( replyMemo( MemoPopupView::SendType, const QString& , const QString& ) ), SLOT( slotReplyMemo( MemoPopupView::SendType, const QString&, const QString& ) ) );
            connect( pMemo1, SIGNAL( deleteMemo( const QString & ) ), SLOT( slotDeleteMemo( const QString & ) ) );
            connect( pMemo1, SIGNAL( closeMemoPopup( MemoPopupView * ) ), SLOT( slotCloseMemoPopup( MemoPopupView * ) ) );
            // }
            pMemo1->setSender( sSender );
            pMemo1->setReceiver( sReceiver );
            pMemo1->setUUID( sMemo.getValue("uuid") );
            QString sTitle( sMemo.getValue("title") );
            QStringList slTitle = QStringList::split( "%0A", sTitle );
            pMemo1->setTitle( slTitle[0] );
            QString sDateTemp( sMemo.getValue("date") );
#ifdef NETDEBUG
            kdDebug() << "[] Title : [" << sMemo.getValue("title") << "]" << endl;
            kdDebug() << "[] Date : [" << sMemo.getValue("date") << "]" << endl;
            kdDebug() << "[] Title[0] : [" << slTitle[0] << "]" << endl;
#endif
            QString sDate;
            sDate = sDateTemp.left(4);
            sDate += "-";
            sDate += sDateTemp.mid(4,2);
            sDate += "-";
            sDate += sDateTemp.mid(6,2);
            sDate += " ";
            sDate += sDateTemp.mid(8,2);
            sDate += ":";
            sDate += sDateTemp.mid(10,2);
            sDate += ":";
            sDate += sDateTemp.mid(12,2);
            pMemo1->setDate( sDate );
            QString sBody2( sMemo.getBody() );
            QStringList slBody = QStringList::split( "\n", sBody2 );
            QString sAMemo;
            for ( QStringList::Iterator it = slBody.begin(); it != slBody.end(); ++it ) {
                  if ( (*it).left(5) == "memo="  ) {
                        sAMemo = (*it).mid( 5, (*it).length() );
                  }
            }
            QRegExp rx("<FONT\\b[^>]*>(.*)</FONT>");

            rx.search( sAMemo, 0 );

#ifdef NETDEBUG
            kdDebug() << "0 : " << rx.cap(0) << endl;
            kdDebug() << "1 : " << rx.cap(1) << endl;
            kdDebug() << "2 : " << rx.cap(2) << endl;
#endif
            
            QString sFixBody( rx.cap(1) );
            sFixBody.replace("%0D", "\n");
            
            pMemo1->setBody( sFixBody );
            pMemo1->show();
            
            /*! 뒤의 "0", "1" 은 안읽음 필드 */
            pSQLiteDB->saveMemoInbox( sMemo.getValue("uuid"), sMemo.getValue("from"), sMemo.getValue("ref"), /* sMemo.getBody() */ sBody, "0" );
      }
      else
      {
            /*! 토스트 창으로 알려주기 */
            Buddy* pBuddy = m_pBuddyList->getBuddyByID( sMemo.getValue("from" ).stripWhiteSpace () );
            if ( pBuddy )
            {
                  QPoint point = systemTrayWidget_->mapToGlobal( systemTrayWidget_->pos() );
                  if ( !pMemoNotify)
                  {
                        pMemoNotify = new PopupWindow();
                        connect(pMemoNotify, SIGNAL( clickText( int, QString ) ), SLOT( slotPopupMemoFromUUID(int, QString ) ) );
                        connect(pMemoNotify, SIGNAL( hidePopup() ), SLOT( slotHidePopup() ) );
                  }
                  
                  int screen = kapp->desktop()->screenNumber();
                  QRect screenSize = kapp->desktop()->availableGeometry(screen);
                  
                  int nX = point.x();
                  int nY = screenSize.height() + screenSize.top();
                  
                  pMemoNotify->setID( sMemo.getValue("uuid") );
                  pMemoNotify->setAnchor( QPoint(nX, nY) );
                  
                  pMemoNotify->setLogo( sPicsPath + "popup_notice_memo.bmp" );
                  
                  QString sMsg;
                  sMsg = pBuddy->getName();
                  
                  QString sNick = pBuddy->getNick();
                  
                  if ( sNick.length() > 10 )
                  {
                        sNick = sNick.left(10);
                        sNick += "...";
                  }
                  
                  Common::fixOutString( sNick );
                  sMsg += "(" + sNick + ")";
                  
                  sMsg += UTF8(" 님으로부터 쪽지가 도착했습니다.");
                  
                  pMemoNotify->setText( sMsg );
                  
                  /*! 0: Online, 1: incoming chat, 2: incoming memo */
                  pMemoNotify->setType(2);
                  pMemoNotify->show();
                  nPopupY++;
                  /*! 뒤의 "0", "1" 은 안읽음 필드 */
                  pSQLiteDB->saveMemoInbox( sMemo.getValue("uuid"), sMemo.getValue("from"), sMemo.getValue("ref"), /* sMemo.getBody() */ sBody, "1" );
                  m_pMainView->slotUpdateMemoCount( pSQLiteDB->getNewMemoCount() );
            }
      }
      /*!
       * saveMemoInbox( from, ref, body, is unread? )
       * 온라인 쪽지에서는 unread가 0 이다.
       */
}


Generated by  Doxygen 1.6.0   Back to index