예제 #1
0
message_view::message_view(QWidget* parent, msg_list_window* sub_parent) : QWidget(parent)
{
  m_pmsg=NULL;
  m_content_type_shown = 0;
  m_zoom_factor=1.0;
  m_parent = sub_parent;
  setAutoFillBackground(true);
  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::Background, Qt::white);
  pal.setColor(QPalette::Inactive, QPalette::Background, Qt::white);
  setPalette(pal);

  enable_page_nav(false, false);
  m_bodyv = new body_view();
  QVBoxLayout* top_layout=new QVBoxLayout(this);
  top_layout->setContentsMargins(0,0,0,0);
  top_layout->setSpacing(0);

  top_layout->addWidget(m_bodyv);

  connect(m_bodyv, SIGNAL(loadFinished(bool)), this, SLOT(load_finished(bool)));
  connect(m_bodyv, SIGNAL(external_contents_requested()), this,
	  SLOT(ask_for_external_contents()));
  connect(m_bodyv, SIGNAL(popup_body_context_menu()), SIGNAL(popup_body_context_menu()));
  if (m_parent) {
    connect(m_bodyv->page(),
	    SIGNAL(linkHovered(const QString&,const QString, const QString&)),
	    this, SLOT(display_link(const QString&)));
  }
  connect(m_bodyv, SIGNAL(linkClicked(const QUrl&)), this, SLOT(link_clicked(const QUrl&)));

  QShortcut* t = new QShortcut(QKeySequence(tr("Ctrl+A", "Select all")), this);
  t->setContext(Qt::WidgetWithChildrenShortcut);
  connect(t, SIGNAL(activated()), this, SLOT(select_all_text()));
}
예제 #2
0
message_view::message_view(QWidget* parent, msg_list_window* sub_parent) : QScrollArea(parent)
{
  m_pmsg=NULL;
  m_content_type_shown = 0;
  m_zoom_factor=1.0;
  m_parent = sub_parent;
  setAutoFillBackground(true);
  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::Background, Qt::white);
  pal.setColor(QPalette::Inactive, QPalette::Background, Qt::white);
  setPalette(pal);

  enable_page_nav(false, false);
  m_headersv = new headers_view();
  m_bodyv = new body_view();
  QVBoxLayout* top_layout=new QVBoxLayout(this);
  m_frame = new QFrame();
  m_frame->setFrameStyle(QFrame::Box | QFrame::Raised);
  m_frame->setLineWidth(0);
  m_frame->setMinimumSize(QSize(200,200));

//  m_frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
  top_layout->addWidget(m_frame);
  QVBoxLayout* l =new QVBoxLayout(m_frame);

  l->setContentsMargins(0,0,0,0);
  l->setSpacing(0);
  l->addWidget(m_headersv);
  l->setStretchFactor(m_headersv, 0);

  l->addWidget(m_bodyv);
  l->setStretchFactor(m_bodyv, 1);

  this->setWidget(m_frame);	// for the scrollarea

  connect(m_bodyv, SIGNAL(wheel(QWheelEvent*)), this, SLOT(wheel_body(QWheelEvent*)));
  connect(m_bodyv, SIGNAL(loadFinished(bool)), this, SLOT(load_finished(bool)));
  connect(m_bodyv, SIGNAL(external_contents_requested()), this,
	  SLOT(ask_for_external_contents()));
  connect(m_bodyv, SIGNAL(key_space_pressed()), this, SLOT(page_down()));
  connect(m_bodyv, SIGNAL(popup_body_context_menu()), SIGNAL(popup_body_context_menu()));
  if (m_parent) {
    connect(m_bodyv->page(),
	    SIGNAL(linkHovered(const QString&,const QString, const QString&)),
	    m_parent, SLOT(show_status_message(const QString&)));
  }
  connect(m_headersv, SIGNAL(fetch_ext_contents()), this, SLOT(allow_external_contents()));
  connect(m_headersv, SIGNAL(to_text()), this, SLOT(show_text_part()));
  connect(m_headersv, SIGNAL(to_html()), this, SLOT(show_html_part()));
  connect(m_headersv, SIGNAL(complete_load_request()), this, SLOT(complete_body_load()));
  m_header_has_selection=false;
  connect(m_headersv, SIGNAL(copyAvailable(bool)), this, SLOT(headers_own_selection(bool)));
  connect(m_headersv, SIGNAL(selectionChanged()), this, SLOT(headers_selection_changed()));
  connect(m_headersv, SIGNAL(msg_display_request()), this, SIGNAL(on_demand_show_request()));
  connect(m_bodyv->page(), SIGNAL(selectionChanged()), this, SLOT(body_selection_changed()));
}
예제 #3
0
body_view::body_view(QWidget* parent) : QWebView(parent)
{
  m_pmsg=NULL;
  m_loaded=false;

  page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
  m_netman = new network_manager(this);
  page()->setNetworkAccessManager(m_netman);
  connect(m_netman, SIGNAL(external_contents_requested()), this,
	  SLOT(ask_perm_for_contents()));

  QWebSettings* settings=page()->settings();
  settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
  settings->setAttribute(QWebSettings::JavascriptEnabled, false);
  settings->setAttribute(QWebSettings::JavaEnabled, false);
  settings->setAttribute(QWebSettings::PluginsEnabled, false);
  settings->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
  
  set_body_style();
}
예제 #4
0
/* outgoingData is always 0 for Get and Head requests */
QNetworkReply*
network_manager::createRequest(Operation op, const QNetworkRequest& req, QIODevice* outgoingData)
{
  DBG_PRINTF(5, "createRequest for %s", req.url().toString().toLocal8Bit().constData());
  if (op!=GetOperation) {
    // only GET is currently supported, see if HEAD should be
    return empty_network_reply(op, req);
  }
  const QUrl& url = req.url();
  // the request refers to attached contents
  if (req.url().scheme() == "cid") {
    // refers to a MIME part that should be attached
    if (m_pmsg) {
      attachment* a = m_pmsg->attachments().get_by_content_id(req.url().path());
      if (a!=NULL) {
	attachment_network_reply* reply = a->network_reply(req, this);
	connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
		this, SLOT(download_error(QNetworkReply::NetworkError)));
	connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
		this, SLOT(download_progress(qint64,qint64)));
	connect(reply, SIGNAL(finished()), this, SLOT(download_finished()));
	return reply;
      }
      
    }
    return empty_network_reply(op, req);
  }
  else if (url.scheme()=="manitou" && (url.authority()=="xface" || url.authority()=="face")) {
    if (url.hasQueryItem("id") && url.hasQueryItem("o")) {
      QString headers = m_pmsg->get_headers();
      bool id_ok, o_ok;
      uint id = url.queryItemValue("id").toUInt(&id_ok);
      int offset = url.queryItemValue("o").toInt(&o_ok);
      if (id_ok && o_ok && id == m_pmsg->get_id()) {
	int lf_pos = headers.indexOf('\n', offset);
	QString ascii_line;
	if (lf_pos>0) {
	  ascii_line = headers.mid(offset, lf_pos-offset);
	}
	else {
	  ascii_line = headers.mid(offset);
	}
	ascii_line.replace(" ", "");
	int type = url.authority()=="face" ? 1:2;
	return new internal_img_network_reply(req, ascii_line, type, this);
      }
    }
    return empty_network_reply(op, req);
  }
  else if (req.url().scheme()=="style") { // internal scheme for styling contents
    return new internal_style_network_reply(req, m_body_style, this);
  }
  // the request refers to external contents
  if (m_ext_download_permitted) {
    //        qDebug() << "op accepted for " << req.url().toString();
    return QNetworkAccessManager::createRequest(op, req, outgoingData);
  }
  else {
    if (!m_ext_download_permission_asked) {
      // let know that contents were skipped so that the user can be
      // presented with the choice to fetch them or not
      emit external_contents_requested();
      m_ext_download_permission_asked=true;
    }
    return empty_network_reply(op, req);
  }
}
예제 #5
0
void
body_view::ask_perm_for_contents()
{
  // transmit signal upwards
  emit external_contents_requested();
}