Пример #1
0
void MWI::publish(const string& user, const string& domain)
{
  int new_msgs = 0;
  int all_msgs = 0;
  string headers, body;
                                            
  AmArg di_args, ret;
  di_args.push(domain.c_str());
  di_args.push(user.c_str());
    
  MessageStorage->invoke("userdir_open",di_args,ret);
    
  if (!ret.size() || !isArgInt(ret.get(0))) {
    ERROR("userdir_open for user '%s' domain '%s' returned no (valid) result.\n", user.c_str(), domain.c_str());
    return;
  };
    
  all_msgs = ret.get(1).size();
  for (size_t i = 0; i < ret.get(1).size(); i++) {
    AmArg& elem = ret.get(1).get(i);
    
    if (elem.get(2).asInt()) // skip empty messages
      new_msgs += elem.get(1).asInt();
    else
      all_msgs--;
  };
                                                  
  DBG("Found %d new and %d old messages\n", new_msgs, all_msgs - new_msgs);
  string vm_buf = int2str(new_msgs) + "/" + int2str(all_msgs - new_msgs);

  headers = "Event: message-summary\r\n";
  headers += "Subscription-State: active\r\n";
    
  if (new_msgs > 0)
    body = "Messages-Waiting: yes\r\n";
  else
    body = "Messages-Waiting: no\r\n";

  body += "Message-Account: sip:" + user + "@" + domain + "\r\n";
  body += "Voice-Message: " + vm_buf + " (" + vm_buf + ")\r\n";

  AmMimeBody sms_body;
  sms_body.addPart("application/simple-message-summary");
  sms_body.setPayload((const unsigned char*)body.c_str(),body.length());

  AmSipDialog tmp_d(NULL);
  tmp_d.local_party = string("<sip:mwi-publisher@") + presence_server + ">";
  tmp_d.remote_party = domain.c_str();
  tmp_d.route = "sip:" + presence_server;
  tmp_d.remote_uri = "sip:" + user + "@" + domain;
  tmp_d.callid = AmSession::getNewId() + "@" + presence_server;
  tmp_d.local_tag = AmSession::getNewId();
  tmp_d.sendRequest(SIP_METH_NOTIFY, &sms_body, headers);     
};
Пример #2
0
int AmSipDialog::transfer(const string& target)
{
  if(status == Connected){

    status = Disconnecting;
		
    string      hdrs = "";
    AmSipDialog tmp_d(*this);
		
    tmp_d.setRoute("");
    tmp_d.contact_uri = "Contact: <" + tmp_d.remote_uri + ">\r\n";
    tmp_d.remote_uri = target;
		
    string r_set;
    if(!route.empty()){
			
      vector<string>::iterator it = route.begin();
      r_set ="Transfer-RR=\"" + *it;
			
      for(it++; it != route.end(); it++)
	r_set += "," + *it;
			
      r_set += "\"";
    }
				
    if (!(next_hop.empty() && route.empty())) {
      hdrs = PARAM_HDR ": ";
      if (!next_hop.empty()) 
	hdrs+="Transfer-NH=\"" + next_hop +"\";";
		  
      if (!r_set.empty()) 
	hdrs+=r_set;
    }
    int ret = tmp_d.sendRequest("REFER","","",hdrs);
    if(!ret){
      uac_trans.insert(tmp_d.uac_trans.begin(),
		       tmp_d.uac_trans.end());
      cseq = tmp_d.cseq;
    }
		
    return ret;
  }
	
  DBG("transfer(): we are not connected "
      "(status=%i). do nothing!\n",status);
    
  return 0;
}
Пример #3
0
int main(int ac, char** av)
{
  if (ac != 2) error_macro("expecting 1 argument: CMAKE_BINARY_DIR")

  std::string
    dir = string(av[1]) + "/paper_GMD_2015/fig_a/",
    h5  = dir + "out_lgrngn",
    svg = dir + "out_lgrngn_spec.svg";

  Gnuplot gp;

  int off = 2; // TODO!!!
  float ymin = .4 * .01, ymax = .9 * 10000;
  const int at = 9000;

  gp << "set term svg dynamic enhanced fsize 15 size 900, 1500 \n";
  gp << "set output '" << svg << "'\n";
  gp << "set logscale xy\n";
  gp << "set xrange [.002:100]\n";
  gp << "set yrange [" << ymin << ":" << ymax << "]\n";
  gp << "set ylabel '[mg^{-1} μm^{-1}]'\n"; // TODO: add textual description (PDF?)
  gp << "set grid\n";
  gp << "set nokey\n";

  // FSSP range
  gp << "set arrow from .5," << ymin << " to .5," << ymax << " nohead\n";
  gp << "set arrow from 25," << ymin << " to 25," << ymax << " nohead\n";

  gp << "set xlabel offset 0,1.5 'particle radius [μm]'\n";
  gp << "set key samplen 1.2\n";
  gp << "set xtics rotate by 65 right (.01, .1, 1, 10, 100) \n";

// TODO: use dashed lines to allow printing in black and white... same in image plots

  assert(focus.first.size() == focus.second.size());
  gp << "set multiplot layout " << focus.first.size() << ",2 columnsfirst upwards\n";

  // focus to the gridbox from where the size distribution is plotted
  char lbl = 'i';
  for (auto &fcs : std::set<std::set<std::pair<int,int>>>({focus.first, focus.second}))
  {
    for (auto it = fcs.begin(); it != fcs.end(); ++it)
    {
      const int &x = it->first, &y = it->second;

      gp << "set label 1 '(" << lbl << ")' at graph -.15, 1.02 font ',20'\n";
      //gp << "set title 'x=" << x << " y=" << y << "'\n";

      std::map<float, float> focus_d;
      std::map<float, float> focus_w;

      //info on the number and location of histogram edges
      vector<quantity<si::length>> left_edges_rd = bins_dry();
      int nsd = left_edges_rd.size() - 1;
      vector<quantity<si::length>> left_edges_rw = bins_wet();
      int nsw = left_edges_rw.size() - 1;

      for (int i = 0; i < nsd; ++i)
      {
	const string name = "rd_rng" + zeropad(i) + "_mom0";
	blitz::Array<float, 2> tmp_d(1e-6 * h5load(h5, name, at));

	focus_d[left_edges_rd[i] / 1e-6 / si::metres] = sum(tmp_d(
	  blitz::Range(x-1, x+1),
	  blitz::Range(y-1, y+1)
	)) 
	/ 9  // mean over 9 gridpoints
	/ ((left_edges_rd[i+1] - left_edges_rd[i]) / 1e-6 / si::metres); // per micrometre
      }

      for (int i = 0; i < nsw; ++i)
      {
	const string name = "rw_rng" + zeropad(i + off) + "_mom0";
	blitz::Array<float, 2> tmp_w(1e-6 * h5load(h5, name, at));

	focus_w[left_edges_rw[i] / 1e-6 / si::metres] = sum(tmp_w(
	  blitz::Range(x-1, x+1),
	  blitz::Range(y-1, y+1)
	)) 
	/ 9 
	/ ((left_edges_rw[i+1] - left_edges_rw[i]) / 1e-6 / si::metres); // per micrometre
      }

      notice_macro("setting-up plot parameters");
      gp << "plot"
	 << "'-' with histeps title 'wet radius' lw 3 lc rgb 'blue'," 
	 << "'-' with histeps title 'dry radius' lw 1 lc rgb 'red' " << endl;
      gp.send(focus_w);
      gp.send(focus_d);

      lbl -= 2;
    }
    lbl = 'j';
  }
}