/******************************************************************* * Main routine for the PCM_OP_DEVICE_POL_SET_STATE operation. *******************************************************************/ void op_device_pol_set_state( cm_nap_connection_t *connp, int32 opcode, int32 flags, pin_flist_t *i_flistp, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Null out results ***********************************************************/ *r_flistpp = NULL; /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_DEVICE_POL_SET_STATE) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_device_pol_set_state opcode error", ebufp); return; } /*********************************************************** * Debut what we got. ***********************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_device_pol_set_state input flist", i_flistp); /*********************************************************** * Main rountine for this opcode ***********************************************************/ fm_device_pol_set_state(ctxp, flags, i_flistp, r_flistpp, ebufp); /*********************************************************** * Error? ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_FLIST_DESTROY_EX(r_flistpp, ebufp); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_device_pol_set_state error", ebufp); } else { PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_device_pol_set_state output flist", *r_flistpp); } return; }
/******************************************************************* * Main routine for the PCM_OP_CUST_POL_READ_PLAN operation. *******************************************************************/ void op_cust_pol_read_plan( cm_nap_connection_t *connp, int32 opcode, int32 flags, pin_flist_t *i_flistp, pin_flist_t **ret_flistpp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; /*********************************************************** * Null out results until we have some. ***********************************************************/ *ret_flistpp = NULL; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_CUST_POL_READ_PLAN) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "bad opcode in op_cust_pol_read_plan", ebufp); return; } /*********************************************************** * Debug: What did we get? ***********************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_read_plan input flist", i_flistp); /*********************************************************** * Call main function to do it ***********************************************************/ fm_cust_pol_read_plan(ctxp, i_flistp, &r_flistp, ebufp); /*********************************************************** * Set the results. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { *ret_flistpp = NULL; PIN_FLIST_DESTROY_EX(&r_flistp, NULL); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_cust_pol_read_plan error", ebufp); } else { *ret_flistpp = r_flistp; PIN_ERR_CLEAR_ERR(ebufp); PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_read_plan return flist", *ret_flistpp); } return; }
//**************************************************** // update_contactinfo // Pre: // Post: // bool bs_UpdateContactInfo::updateContactInfo( pin_Session * pinp, poid_t * account_pdp, bs_SignupRec * bsrp, string source, pin_flist_t **return_flistpp, pin_errbuf_t *ebufp ) { pin_flist_t * c_outflistp = NULL; pin_flist_t * c_flistp = NULL; pin_flist_t * t1_flistp = NULL; pin_flist_t * t2_flistp = NULL; pin_flist_t * outflistp = NULL; void * vp = NULL; int32 flags = 0; /* source name */ /* source / desc name */ const string this_program("bs_UpdateContactInfo::updateContactInfo"); if ( source.empty() ) { source.assign(this_program); } PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, (char*)this_program.c_str() ); //--- get appropriate fields ---------- char * firstname = bsrp->s_firstName; char * lastname = bsrp->s_lastName; char * address = bsrp->s_caddress; char * city = bsrp->s_ccity; char * state = bsrp->s_cstate; char * zip = bsrp->s_czip; char * email_addr = bsrp->s_cemail_addr; int32 contact_type = PIN_NAMEINFO_BILLING; const char * country = "USA"; const char * program_name = source.c_str(); PIN_ERR_CLEAR_ERR(ebufp); /* create flist */ c_flistp = PIN_FLIST_CREATE( ebufp ); /* top level fields */ PIN_FLIST_FLD_SET(c_flistp, PIN_FLD_POID,(void *)account_pdp, ebufp); PIN_FLIST_FLD_SET(c_flistp, PIN_FLD_PROGRAM_NAME,(void *)program_name, ebufp); /* nameinfo */ t1_flistp = PIN_FLIST_ELEM_ADD(c_flistp, PIN_FLD_NAMEINFO, contact_type, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_FIRST_NAME,(void *)firstname, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_LAST_NAME,(void *)lastname, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_ADDRESS,(void *)address, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_CITY,(void *)city, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_STATE,(void *)state, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_ZIP,(void *)zip, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_COUNTRY,(void *)country, ebufp); PIN_FLIST_FLD_SET(t1_flistp, PIN_FLD_EMAIL_ADDR,(void *)email_addr, ebufp); PIN_ERR_CLEAR_ERR(ebufp); bool rc = pinp->call_opcode( PCM_OP_CUST_POL_UOL_SET_NAMEINFO, flags, c_flistp, &c_outflistp, ebufp); if (c_flistp) PIN_FLIST_DESTROY(c_flistp,ebufp); if (c_outflistp) PIN_FLIST_DESTROY_EX(&c_outflistp,ebufp); return rc; }
/******************************************************************* * Main routine for the PCM_OP_PYMT_POL_CHARGE operation. *******************************************************************/ void op_pymt_pol_charge( cm_nap_connection_t *connp, int opcode, int flags, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *r_flistp = NULL; pcm_context_t *ctxp = connp->dm_ctx; if (PIN_ERR_IS_ERR(ebufp)) { return ; } PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_PYMT_POL_CHARGE) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_pymt_pol_charge opcode error", ebufp); return; } /*********************************************************** * Debug: The input Flist ***********************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_pymt_pol_charge input flist", i_flistp); /********************************************************** * Copy the input flist to r_flsitp as. Do not change the * Input Flist *********************************************************/ r_flistp = PIN_FLIST_COPY(i_flistp,ebufp); fm_pymt_pol_charge(ctxp, i_flistp, r_flistp,ebufp); if (PIN_ERR_IS_ERR(ebufp)) { /*************************************************** * Log something and return nothing. **************************************************/ PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_pymt_pol_charge error", ebufp); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); *o_flistpp = NULL; } else { /*************************************************** * Point the real return flist to the right thing. ***************************************************/ *o_flistpp = r_flistp; /*************************************************** * Debug: What we're sending back. ***************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_pymt_pol_charge return flist", r_flistp); } return; }
/* * Search for a brand name in the whole system. */ static void fm_cust_pol_is_brandname_unique_global( pcm_context_t *ctxp, poid_t *poidp, char *namep, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *flistp = (pin_flist_t *)NULL; pin_flist_t *rlistp = (pin_flist_t *)NULL; pin_flist_t *sublistp; poid_t *search_poidp; int32 int_val; int32 cred; pin_account_type_t brand_type = PIN_ACCOUNT_TYPE_BRAND; pin_cookie_t cookie = (pin_cookie_t)NULL; /* * If there are pending errors, then short circuit immediately */ if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /* * Create search flist to try to figure out if someone brand already * has this name. * * NOTE: we really only need to search for accounts that are of type * 'brand' and of a particular name. Unfortunately, neither of these * fields are indexed by default, thus causing a performance problem. * * To get around this, we'll turn this into a complex search. We know * that brands are the parent of a /group/billing object, so glue that * in as well. That should be indexed... */ flistp = PIN_FLIST_CREATE(ebufp); search_poidp = PIN_POID_CREATE(PIN_POID_GET_DB(poidp), "/search", -1, ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, (void *)search_poidp, ebufp); int_val = SRCH_DISTINCT; PIN_FLIST_FLD_SET(flistp, PIN_FLD_FLAGS, (void *)&int_val, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_TEMPLATE, (void *)"select X from /account 1, /group 2 where 1.F1 = V1 " "AND 1.F2 = V2 AND 1.F3 = 2.F4 AND 1.F5 != V5 ", ebufp); PIN_FLIST_ELEM_SET(flistp, NULL, PIN_FLD_RESULTS, 0, ebufp); /* * Arg 1 is the type of the account; only interested in brand accounts */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_ACCOUNT_TYPE, (void *)&brand_type, ebufp); /* * Arg 2 is the name of the brand. */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 2, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_NAME, (void *)namep, ebufp); /* * Arg 3 -- POID of account */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 3, ebufp); PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_POID, NULL, ebufp); /* * Arg 4 -- Parent of the group */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 4, ebufp); PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_PARENT, NULL, ebufp); /* * Arg 5 -- POID of current account */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 5, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_POID, poidp, ebufp); /* * Ready to search! Temporarily suspend search to ensure that * all brands are traversed. */ cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); PCM_OP(ctxp, PCM_OP_GLOBAL_SEARCH, PCM_OPFLG_COUNT_ONLY, flistp, &rlistp, ebufp); CM_FM_END_OVERRIDE_SCOPE(cred); /* * See if there is a brand out there right now that already has * this name. If so, flag it as an error. */ PIN_FLIST_ELEM_GET_NEXT(rlistp, PIN_FLD_RESULTS, &int_val, 1, &cookie, ebufp); if(int_val > 0) { *r_flistpp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_POID, (void *)poidp, ebufp); fm_cust_pol_valid_add_fail(*r_flistpp, PIN_FLD_NAME, 0, PIN_CUST_VAL_ERR_DUPE, PIN_CUST_DUPE_VALUE_ERR_MSG, (void *)namep, ebufp); pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_DUPLICATE, PIN_FLD_NAME, 0, 0); } /* * Cleanup and return */ PIN_FLIST_DESTROY_EX(&flistp, NULL); PIN_FLIST_DESTROY_EX(&rlistp, NULL); }
/******************************************************************* * Main routine for the PCM_OP_CUST_POL_PREP_INHERITED command *******************************************************************/ void op_cust_pol_prep_inherited( cm_nap_connection_t *connp, u_int opcode, u_int flags, pin_flist_t *in_flistp, pin_flist_t **ret_flistpp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; /*********************************************************** * Null out results until we have some. ***********************************************************/ *ret_flistpp = NULL; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_CUST_POL_PREP_INHERITED) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "bad opcode in op_cust_pol_prep_inherited", ebufp); return; } /****************************************************************** * Debug: What we got. ******************************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_prep_inherited input flist", in_flistp); /*********************************************************** * We will not open any transactions with Policy FM * since policies should NEVER modify the database. ***********************************************************/ /*********************************************************** * Call main function to do it ***********************************************************/ fm_cust_pol_prep_inherited(ctxp, in_flistp, &r_flistp, ebufp); /*********************************************************** * Results. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { *ret_flistpp = (pin_flist_t *)NULL; PIN_FLIST_DESTROY_EX(&r_flistp, NULL); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_cust_pol_prep_inherited error", ebufp); } else { *ret_flistpp = r_flistp; PIN_ERR_CLEAR_ERR(ebufp); PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_prep_inherited return flist", r_flistp); } return; }
//**************************************************** // updateStatus // Pre: // Post: // bool bs_UpdateStatus::updateStatus( pin_Session * pinp, poid_t * account_pdp, poid_t * service_pdp, int status, int status_flags, string source, string description, pin_flist_t **return_flistpp, pin_errbuf_t *ebufp ) { pin_flist_t * x_flistp = NULL; pin_flist_t * d_flistp = NULL; pin_flist_t * f_flistp = NULL; pin_flist_t * f_outflistp = NULL; pin_errbuf_t localebuf; int flag=status_flags; poid_t * pdp = NULL; void * vp = NULL; bool rc; const string this_program("updateStatus"); if ( source.empty() ) { source.assign(this_program); } if ( description.empty() ) { description.assign(this_program); } PIN_ERR_CLEAR_ERR(ebufp); //--enter function-------------- PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, (char*)this_program.c_str() ); /*--- Create set_status ---*/ if ( status == PIN_STATUS_ACTIVE && status_flags <= 0 ) { PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_ERROR, (char*)"This is an activation - get existing flags" ); PIN_ERR_CLEAR_ERR(&localebuf); pdp = ( pin_poid_is_null(service_pdp)) ? account_pdp : service_pdp; f_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_POID, (void*)pdp, &localebuf); PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_STATUS_FLAGS, (void*)NULL, &localebuf); if ( pinp->call_opcode( PCM_OP_READ_FLDS, 0, f_flistp, &f_outflistp, &localebuf)) { if ((vp=PIN_FLIST_FLD_GET( f_outflistp, PIN_FLD_STATUS_FLAGS, 1, &localebuf )) != NULL ) status_flags = *(int*)vp; } if (f_flistp) PIN_FLIST_DESTROY(f_flistp,NULL); f_flistp = NULL; if (f_outflistp) PIN_FLIST_DESTROY_EX(&f_outflistp,NULL); f_outflistp = NULL; } if ( status_flags < 0) { status_flags = 0; } /*--- Create set_status ---*/ x_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_POID, account_pdp, ebufp); if ( ! pin_poid_is_null(service_pdp) ) PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_SERVICE_OBJ, service_pdp, ebufp); PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_PROGRAM_NAME, (void*)source.c_str(), ebufp); PIN_FLIST_FLD_SET(x_flistp, PIN_FLD_DESCR, (void*)description.c_str(), ebufp); d_flistp = PIN_FLIST_ELEM_ADD( x_flistp, PIN_FLD_STATUSES, PIN_ELEMID_ASSIGN, ebufp ); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_STATUS, (void*)&status, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_STATUS_FLAGS, (void*)&status_flags, ebufp); if ( (! pin_poid_is_null(service_pdp)) && (status == PIN_STATUS_CLOSED) ) { rc = pinp->call_opcode( PCM_OP_CUST_SET_STATUS, 0, x_flistp, return_flistpp, ebufp); } else { rc = pinp->call_opcode( UOL_OP_SET_STATUS, 0, x_flistp, return_flistpp, ebufp); } PIN_ERR_LOG_FLIST( PIN_ERR_LEVEL_DEBUG,(char*)"leaving bs_UpdateStatus::updateStatus" , *return_flistpp ); if (x_flistp) PIN_FLIST_DESTROY(x_flistp,NULL); return rc; }
/********************************************************************** * fm_pymt_pol_spec_collect_get_ach() * Get ACH information **********************************************************************/ static void fm_pymt_pol_spec_collect_get_ach( pcm_context_t *ctxp, int32 flags, pin_flist_t *i_flistp, pin_flist_t *o_flistp, pin_errbuf_t *ebufp) { void *vp = NULL; pin_flist_t *flistp = NULL; pin_flist_t *p_flistp = NULL; pin_flist_t *rp_flistp = NULL; pin_flist_t *a_flistp = NULL; pin_flist_t *ra_flistp = NULL; int32 rec_id = 0; poid_t *p_pdp = NULL; poid_t *a_pdp = NULL; if (PIN_ERR_IS_ERR(ebufp)) { return; } PIN_ERR_CLEAR_ERR(ebufp); p_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_PAYINFO_OBJ, 0, ebufp); a_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); /** read the payinfo to get the ach pointer. **/ p_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(p_flistp, PIN_FLD_POID, p_pdp, ebufp); PIN_FLIST_FLD_SET(p_flistp, PIN_FLD_ACH, &rec_id, ebufp); PCM_OP(ctxp, PCM_OP_READ_FLDS, PCM_OPFLG_READ_UNCOMMITTED, p_flistp, &rp_flistp, ebufp); if (rp_flistp != (pin_flist_t *)NULL) { vp = PIN_FLIST_FLD_GET(rp_flistp, PIN_FLD_ACH, 0, ebufp); if (vp) { rec_id = *(int32 *)vp; } a_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, a_pdp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_ACH, (void *) &rec_id, ebufp); PCM_OP(ctxp, PCM_OP_PYMT_GET_ACH_INFO, 0, a_flistp, &ra_flistp, ebufp); flistp = PIN_FLIST_ELEM_GET(ra_flistp, PIN_FLD_RESULTS, 0, PIN_ELEMID_ANY, ebufp); vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_MERCHANT, 0, ebufp); PIN_FLIST_FLD_SET(o_flistp, PIN_FLD_MERCHANT, vp, ebufp); PIN_FLIST_FLD_SET(o_flistp, PIN_FLD_ACH, (void *) &rec_id, ebufp); vp = PIN_FLIST_FLD_TAKE(flistp, PIN_FLD_POID_VAL, 0, ebufp); flistp = PIN_FLIST_ELEM_ADD(o_flistp, PIN_FLD_BATCH_INFO, 0, ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID_VAL, vp, ebufp); } if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_spec_collect_get_ach error", ebufp); } PIN_FLIST_DESTROY_EX(&p_flistp, NULL); PIN_FLIST_DESTROY_EX(&rp_flistp, NULL); PIN_FLIST_DESTROY_EX(&a_flistp, NULL); PIN_FLIST_DESTROY_EX(&ra_flistp, NULL); return; }
/**************************************************************** * Function : fm_cust_pol_prep_create_sponsored_topup * Description : This function will prepare the flist for * creating the sponsored topup operation. ****************************************************************/ static void fm_cust_pol_prep_create_sponsored_topup( pcm_context_t *ctxp, int32 flags, pin_flist_t *i_flistp, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { poid_t *initiator_pdp = NULL; poid_t *parent_pdp = NULL; poid_t *balgrp_pdp = NULL; poid_t *s_pdp = NULL; poid_t *grp_pdp = NULL; pin_flist_t *topup_flistp = NULL; pin_flist_t *ingrptopup_flistp = NULL; pin_flist_t *ingrplmt_flistp = NULL; pin_flist_t *ingrpmem_flistp = NULL; pin_flist_t *tmp_flistp = NULL; pin_flist_t *args1_flistp = NULL; pin_flist_t *args2_flistp = NULL; pin_flist_t *args3_flistp = NULL; pin_flist_t *outtopup_flistp = NULL; pin_flist_t *outgrpmem_flistp = NULL; pin_flist_t *outgrptopup_flistp= NULL; pin_flist_t *reslt_flistp = NULL; pin_flist_t *f_flistp = NULL; pin_flist_t *s_flistp = NULL; pin_flist_t *r_flistp = NULL; char *grp_name = NULL; char *s_tmplt = NULL; int *res_id = NULL; int *topup_interval = NULL; int64 db_no = 0; int search_flag = 256; time_t nexttopup; time_t now; void *vp; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); initiator_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); topup_flistp = PIN_FLIST_ELEM_GET(i_flistp, PIN_FLD_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); ingrptopup_flistp = PIN_FLIST_ELEM_GET(topup_flistp, PIN_FLD_GROUP_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); ingrpmem_flistp = PIN_FLIST_ELEM_GET(ingrptopup_flistp, PIN_FLD_GROUP_TOPUP_MEMBERS, PIN_ELEMID_ANY, 0, ebufp); ingrplmt_flistp = PIN_FLIST_ELEM_GET(ingrptopup_flistp, PIN_FLD_GROUP_TOPUP_LIMITS, PIN_ELEMID_ANY, 0, ebufp); /**************************************************************** * Update the NEXT_TOPUP_T in the out put flist. ****************************************************************/ outtopup_flistp = PIN_FLIST_ELEM_GET(*r_flistpp, PIN_FLD_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); outgrptopup_flistp = PIN_FLIST_ELEM_GET(outtopup_flistp, PIN_FLD_GROUP_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); outgrpmem_flistp = PIN_FLIST_ELEM_GET(outgrptopup_flistp, PIN_FLD_GROUP_TOPUP_MEMBERS, PIN_ELEMID_ANY, 0, ebufp); topup_interval = PIN_FLIST_FLD_GET(outgrpmem_flistp, PIN_FLD_TOPUP_INTERVAL, 0, ebufp); if (PIN_ERR_IS_ERR(ebufp)) return; vp = PIN_FLIST_FLD_GET(ingrpmem_flistp , PIN_FLD_NEXT_TOPUP_T, 1, ebufp); if(vp){ PIN_FLIST_FLD_SET(outgrpmem_flistp, PIN_FLD_NEXT_TOPUP_T, vp, ebufp); }else{ now = pin_virtual_time((time_t *) NULL); nexttopup = now + ((*topup_interval) * 24 * 60 * 60 ); PIN_FLIST_FLD_SET(outgrpmem_flistp, PIN_FLD_NEXT_TOPUP_T, &nexttopup, ebufp); } grp_name = PIN_FLIST_FLD_GET(ingrptopup_flistp, PIN_FLD_NAME, 1, ebufp); grp_pdp = PIN_FLIST_FLD_GET(ingrptopup_flistp, PIN_FLD_POID, 0, ebufp); /**************************************************************** * check if the group poid is type only or not and also * it has the name or not. ****************************************************************/ if( PIN_POID_IS_TYPE_ONLY(grp_pdp) || !grp_name ) { /**************************************************************** * If the group name or the group poid is not defind in the * input flist then search /group/topup for the particular * parent and set the name and the group poid. ****************************************************************/ parent_pdp = PIN_FLIST_FLD_GET(ingrptopup_flistp, PIN_FLD_PARENT, 0, ebufp); balgrp_pdp = PIN_FLIST_FLD_GET(ingrptopup_flistp, PIN_FLD_BAL_GRP_OBJ, 0, ebufp); res_id = PIN_FLIST_FLD_GET(ingrplmt_flistp, PIN_FLD_RESOURCE_ID, 0, ebufp); db_no = PIN_POID_GET_DB(initiator_pdp); s_flistp = PIN_FLIST_CREATE(ebufp); s_pdp = PIN_POID_CREATE(db_no, "/search", -1, ebufp); s_tmplt = " select X from /group/topup where F1 = V1 and F2 = V2 and F3 = V3 "; PIN_FLIST_FLD_PUT(s_flistp, PIN_FLD_POID, s_pdp, ebufp); PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_TEMPLATE, s_tmplt, ebufp); PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_FLAGS, &search_flag, ebufp); tmp_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(tmp_flistp, PIN_FLD_PARENT, parent_pdp, ebufp); args1_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(args1_flistp, PIN_FLD_BAL_GRP_OBJ, balgrp_pdp, ebufp); f_flistp = PIN_FLIST_CREATE(ebufp); if( grp_name == NULL ) { /**************************************************************** * if the group name is null then the search argument will contain * the resource id. ****************************************************************/ args3_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_RESOURCE_ID, res_id, ebufp); PIN_FLIST_ELEM_PUT(args3_flistp, f_flistp, PIN_FLD_GROUP_TOPUP_LIMITS, PCM_RECID_ALL, ebufp); PIN_FLIST_ELEM_PUT(s_flistp, args3_flistp, PIN_FLD_ARGS, 3, ebufp); } else { PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_NAME, grp_name, ebufp); PIN_FLIST_ELEM_PUT(s_flistp, f_flistp, PIN_FLD_ARGS, 3, ebufp); } PIN_FLIST_ELEM_PUT(s_flistp, tmp_flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_ELEM_PUT(s_flistp, args1_flistp, PIN_FLD_ARGS, 2, ebufp); reslt_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(reslt_flistp, PIN_FLD_NAME, "",ebufp); PIN_FLIST_ELEM_PUT(s_flistp, reslt_flistp, PIN_FLD_RESULTS, 0, ebufp); PCM_OP(ctxp, PCM_OP_SEARCH, flags, s_flistp, &r_flistp, ebufp); PIN_FLIST_DESTROY_EX(&s_flistp, NULL); tmp_flistp = PIN_FLIST_ELEM_GET(r_flistp, PIN_FLD_RESULTS, 0, 1, ebufp); /**************************************************************** * If the results array of search contains any record then select the * finst element of the results array and set the group poid and name * else don't set it. ****************************************************************/ if( tmp_flistp != NULL ) { grp_name = PIN_FLIST_FLD_GET(tmp_flistp, PIN_FLD_NAME, 0, ebufp); grp_pdp = PIN_FLIST_FLD_GET(tmp_flistp, PIN_FLD_POID, 0, ebufp); f_flistp = PIN_FLIST_ELEM_GET(outtopup_flistp, PIN_FLD_GROUP_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_NAME, grp_name, ebufp); PIN_FLIST_FLD_SET(f_flistp, PIN_FLD_POID, grp_pdp, ebufp); } PIN_FLIST_DESTROY_EX(&r_flistp, NULL); } if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_prep_create_sponsored_topup error", ebufp); } return; }
/******************************************************************* * Main routine for the PCM_OP_PYMT_POL_COLLECT operation. *******************************************************************/ void op_pymt_pol_collect( cm_nap_connection_t *connp, int opcode, int flags, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; int *cmdp = NULL; pin_flist_t *e_flistp = NULL; pin_cookie_t cookie = NULL; int32 elemid = 0; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_PYMT_POL_COLLECT) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_pymt_pol_collect opcode error", ebufp); return; } /*********************************************************** * Debug: What we got. ***********************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_pymt_pol_collect input flist", i_flistp); /*********************************************************** * Prep the return flist. ***********************************************************/ r_flistp = PIN_FLIST_CREATE(ebufp); /****************************************************** * Addition of PIN_FLD_EVENTS in output flist ******************************************************/ while ((e_flistp = PIN_FLIST_ELEM_GET_NEXT(i_flistp, PIN_FLD_EVENTS, &elemid, 1, &cookie, ebufp)) != (pin_flist_t *)NULL) { PIN_FLIST_ELEM_SET(r_flistp, e_flistp, PIN_FLD_EVENTS, elemid, ebufp); } cmdp = (int *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_COMMAND, 0, ebufp); if (cmdp && *cmdp == PIN_CHARGE_CMD_NONE){ /*********************************************************** * Processing for PIN_CHARGE_CMD_NONE ***********************************************************/ fm_pymt_pol_collect_command_none(ctxp, i_flistp, flags, &r_flistp, ebufp); } else { /*********************************************************** * Fill in the results. ***********************************************************/ fm_pymt_pol_collect_result(ctxp, i_flistp, r_flistp, ebufp); } /*********************************************************** * Results. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { /*************************************************** * Log something and return nothing. ***************************************************/ PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_pymt_pol_collect error", ebufp); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); *o_flistpp = NULL; } else { /*************************************************** * Point the real return flist to the right thing. ***************************************************/ PIN_ERR_CLEAR_ERR(ebufp); *o_flistpp = r_flistp; /*************************************************** * Debug: What we're sending back. ***************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_pymt_pol_collect return flist", r_flistp); } return; }
static void fm_pymt_pol_collect_command_none( pcm_context_t *ctxp, pin_flist_t *flistp, int flags, pin_flist_t **r_flistp, pin_errbuf_t *ebufp) { void *vp = NULL; int dummy = PIN_RESULT_FAIL; char writeoff_rev_level[8] = { "" }; int writeoff_rev_flag = 0; pin_flist_t *res_flistp = NULL; char *pdp = NULL; res_flistp = PIN_FLIST_ELEM_TAKE(flistp, PIN_FLD_RESULTS, 0, 1, ebufp); /****************************************** * Appending Fields from PIN_FLD_RESULTS * into output flist ******************************************/ if (res_flistp) { PIN_FLIST_CONCAT(*r_flistp, res_flistp, ebufp); } PIN_FLIST_DESTROY_EX(&res_flistp, NULL) /******************************************* * Set the result to pass. *******************************************/ vp = PIN_FLIST_FLD_GET(*r_flistp, PIN_FLD_POID, 1, ebufp); if(!vp){ vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_POID, 0, ebufp); PIN_FLIST_FLD_SET(*r_flistp, PIN_FLD_POID, vp, ebufp); } pdp = (char *)PIN_POID_GET_TYPE((poid_t *)vp); /******************************************* * If the poid is /event/billing/payment or * /event/billing/refund then only consider * payment or refund as successful. *******************************************/ if (pdp && (strstr(pdp,"/event/billing/"))) { dummy = PIN_RESULT_PASS; } else { dummy = PIN_RESULT_FAIL; } PIN_FLIST_FLD_SET(*r_flistp, PIN_FLD_RESULT, (void *)&dummy, ebufp); dummy = 0; PIN_FLIST_FLD_SET(*r_flistp, PIN_FLD_TYPE, (void *)&dummy, ebufp); /*********************************************************** * Write-off account action happens only in case when Automatic * WOR feature is enabled and the writeoff * level set to "account" (account) in /config/business_params ***********************************************************/ writeoff_rev_flag = psiu_bparams_get_int(ctxp, PSIU_BPARAMS_AR_PARAMS, PSIU_BPARAMS_AR_AUTO_WO_REV_ENABLE, ebufp); if (writeoff_rev_flag && psiu_bparams_get_str(ctxp, PSIU_BPARAMS_AR_PARAMS, PSIU_BPARAMS_AR_WRITEOFF_LEVEL, writeoff_rev_level, 8, ebufp)) { if ( writeoff_rev_level && strcmp(writeoff_rev_level, PIN_WRITEOFF_REV_LEVEL_ACCOUNT) == 0 ){ fm_pymt_pol_collect_writeoff_account(ctxp, flistp, flags, ebufp); } } if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_collect_command_none error", ebufp); } return; }
/******************************************************************* * fm_bill_pol_stop_billing(): * * This checks the following conditions: * 1) The stop_bill_closed_accounts stanza from the pin.conf file (for CM) * should not be zero * 2) Account has a closed status * 3) The billing is provided for the last (final) billing state * 4) Total due for open and pending items is zero * 5) This is a last accounting cycle in the multi-month billing cycle * * If all these conditions are satisfied then the function calls the * PCM_OP_BILL_SUSPEND_BILLING opcode to stop billing. *******************************************************************/ static void fm_bill_pol_stop_billing( pcm_context_t *ctxp, int32 flags, pin_flist_t *i_flistp, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *i_pol_flistp = NULL; pin_flist_t *o_pol_flistp = NULL; void *vp = NULL; pin_status_t *statusp = NULL; int32 *cycles_leftp = NULL; int32 *bill_whenp = NULL; int32 *bill_typep = NULL; int32 f = PIN_BILL_FLAGS_DUE_TO_STOP_BILL_CLOSE_ACCT; pin_bill_billing_state_t *billing_statep = NULL; pin_decimal_t *due = NULL; pin_decimal_t *due_tot = NULL; if (PIN_ERR_IS_ERR(ebufp)) { return; } PIN_ERR_CLEAR_ERR(ebufp); *r_flistpp = PIN_FLIST_CREATE(ebufp); vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_POID, vp, ebufp); /*********************************************************** * Check the conditions to stop billing ************************************************************/ if (!pin_conf_stop_bill_closed_accounts) { goto cleanup; } billing_statep = (pin_bill_billing_state_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_BILLING_STATE, 0, ebufp); if (billing_statep && (*billing_statep != PIN_ACTG_CYCLE_OPEN)) { goto cleanup; } statusp = (pin_status_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_STATUS, 0, ebufp); if (statusp && (*statusp != PIN_STATUS_CLOSED)) { goto cleanup; } due_tot = pin_decimal ("0.0", ebufp); due = (pin_decimal_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_OPEN_BAL, 1, ebufp); if (due) { pin_decimal_add_assign(due_tot, due, ebufp); } due = (pin_decimal_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_PENDING_BAL, 1, ebufp); if (due) { pin_decimal_add_assign(due_tot, due, ebufp); } if (!pbo_decimal_is_zero(due_tot, ebufp)) { goto cleanup; } bill_whenp = (int32 *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_BILL_WHEN, 0, ebufp); cycles_leftp = (int32 *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_BILL_ACTGCYCLES_LEFT, 0, ebufp); if (!bill_whenp || !cycles_leftp) { goto cleanup; } if (*bill_whenp != *cycles_leftp) { goto cleanup; } bill_typep = (int32 *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_PAY_TYPE, 1, ebufp); if (bill_typep && *bill_typep == PIN_PAY_TYPE_SUBORD) { f = PIN_BILL_FLAGS_DUE_TO_STOP_BILL_CLOSE_ACCT_SUBORD; } /*********************************************************** * Call the PCM_OP_BILL_SUSPEND_BILLING opcode to stop billing ************************************************************/ i_pol_flistp = PIN_FLIST_CREATE(ebufp); vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); PIN_FLIST_FLD_SET(i_pol_flistp, PIN_FLD_POID, vp, ebufp); PIN_FLIST_FLD_SET(i_pol_flistp, PIN_FLD_BILLING_STATUS_FLAGS, (void *)&f, ebufp); PCM_OP(ctxp, PCM_OP_BILL_SUSPEND_BILLING, flags, i_pol_flistp, &o_pol_flistp, ebufp); cleanup: PIN_FLIST_DESTROY_EX(&i_pol_flistp, ebufp); PIN_FLIST_DESTROY_EX(&o_pol_flistp, ebufp); PIN_DECIMAL_DESTROY_EX(&due_tot); if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_bill_pol_stop_billing", ebufp); } return; }
/******************************************************************* * Main routine for the PCM_OP_CUST_POL_GET_PLANS operation. *******************************************************************/ void op_cust_pol_get_plans( cm_nap_connection_t *connp, int opcode, int flags, pin_flist_t *i_flistp, pin_flist_t **ret_flistpp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; pin_flist_t *auth_flistp = NULL; int *auth_result = 0; /*********************************************************** * Null out results until we have some. ***********************************************************/ *ret_flistpp = NULL; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_CUST_POL_GET_PLANS) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "bad opcode in op_cust_pol_get_plans", ebufp); return; } /*********************************************************** * Debug: What did we get? ***********************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_get_plans input flist", i_flistp); #ifdef BILL_GROUP_AUTHORIZATION /****************************************************************** * check to see the PIN_FLD_USERID is allowed to change password * for this account. ******************************************************************/ fm_utils_verify_relation(connp, i_flistp, opcode, &auth_flistp, ebufp); if (PIN_ERR_IS_ERR(ebufp)) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_AUTHORIZATION_FAIL, 0, 0, 0); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_cust_pol_get_plans authorization error", ebufp); PIN_FLIST_DESTROY_EX(&auth_flistp, NULL); return; } auth_result = PIN_FLIST_FLD_GET(auth_flistp, PIN_FLD_RESULT, 0, ebufp); if (auth_result && *auth_result != PIN_BOOLEAN_TRUE) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_AUTHORIZATION_FAIL, 0, 0, 0); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_cust_pol_get_plans authorization error", ebufp); PIN_FLIST_DESTROY_EX(&auth_flistp, NULL); return; } PIN_FLIST_DESTROY_EX(&auth_flistp, NULL); #endif /* BILL_GROUP_AUTHORIZATION */ /*********************************************************** * Call main function to do it ***********************************************************/ fm_cust_pol_get_plans(ctxp, i_flistp, &r_flistp, ebufp); /*********************************************************** * Set the results. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { *ret_flistpp = (pin_flist_t *)NULL; PIN_FLIST_DESTROY_EX(&r_flistp, NULL); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_cust_pol_get_plans error", ebufp); } else { *ret_flistpp = r_flistp; PIN_ERR_CLEAR_ERR(ebufp); PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_get_plans return flist", r_flistp); } return; }
/******************************************************************* * fm_cust_pol_get_plans_read(): *******************************************************************/ static void fm_cust_pol_get_plans_read( pcm_context_t *ctxp, int64 brand_db, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; poid_t *p_plan_pdp = NULL; poid_t *b_plan_pdp = NULL; int32 cred; int32 override_cred= PIN_BOOLEAN_FALSE; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /* * Create the flist for reading the plan * We should read the plan object from the database in which the * brand lives. (Currently only the root brand can span databases). * This is done by replacing the database number of the plan * poid retrieved from the primary database. Note that this is an * acceptable transformation since all the pricelist objects * always get created in the main database. */ flistp = PIN_FLIST_CREATE(ebufp); p_plan_pdp = (poid_t*) PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_OBJECT, 0, ebufp); b_plan_pdp = PIN_POID_CREATE(brand_db, PIN_POID_GET_TYPE(p_plan_pdp), PIN_POID_GET_ID(p_plan_pdp), ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, b_plan_pdp, ebufp); /* * In a multi db system, if the brand_poid and plan_poid are in * different databases, then we need to disable branding due to * a low level design flaw in the brand scoping area. */ if (cm_fm_is_multi_db() ) { cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); override_cred= PIN_BOOLEAN_TRUE; } /* * Read the plan. */ PCM_OP(ctxp, PCM_OP_READ_OBJ, PCM_OPFLG_ORDER_BY_REC_ID, flistp, o_flistpp, ebufp); /* * if this was multi-db and the error is it can't find the object poid * then it may not have been replicated yet */ if ( ebufp->pin_err == PIN_ERR_NOT_FOUND && ebufp->field == PIN_FLD_POID && override_cred == PIN_BOOLEAN_TRUE ) { PIN_ERR_CLEAR_ERR(ebufp); *o_flistpp = NULL; } /* * Re-enable branding if necessary. */ if (override_cred == PIN_BOOLEAN_TRUE) { CM_FM_END_OVERRIDE_SCOPE(cred); override_cred= PIN_BOOLEAN_FALSE; } /* * Clean up. */ PIN_FLIST_DESTROY_EX(&flistp, NULL); if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_get_plans_read error", ebufp); } return; }
/******************************************************************* * fm_cust_pol_get_plans_search(): *******************************************************************/ static void fm_cust_pol_get_plans_search( pcm_context_t *ctxp, int64 database, char *name, char *type, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pin_cookie_t cookie = NULL; pin_flist_t *s_flistp = NULL; pin_flist_t *r_flistp = NULL; pin_flist_t *flistp = NULL; poid_t *pdp = NULL; poid_t *brand_poidp = NULL; int32 cred = 0; int32 element_id; u_int uint_val; /* * Safety check. */ if ((name == (char *)NULL) || (type == (char *)NULL)) { return; } /* * Create the search flist * * In a branding configuration, it is possible that the * account A belonging to a brand B might reside in a non-primary * database. This implies that DM does not have information about * the brand B owner to do the appropriate scoping. Therefore, we * should disable the scoping temporarily for this search. * * Since we disable scoping, we need explicitly filter out the * plan lists that do not belong to this brand using the brand owner * in the query. * */ s_flistp = PIN_FLIST_CREATE(ebufp); pdp = PIN_POID_CREATE(database, "/search", (int64)-1, ebufp); PIN_FLIST_FLD_PUT(s_flistp, PIN_FLD_POID, (void *)pdp, ebufp); uint_val = SRCH_DISTINCT; PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_FLAGS, (void *)&uint_val, ebufp); PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_TEMPLATE, (void *) "select X from /group/$1 where " "F1 = V1 and F2 = V2 and F3 = V3 and F4 = V4", ebufp); PIN_FLIST_FLD_SET(s_flistp, PIN_FLD_PARAMETERS, (void *)"plan_list", ebufp); flistp = PIN_FLIST_ELEM_ADD(s_flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_NAME, (void *)name, ebufp); flistp = PIN_FLIST_ELEM_ADD(s_flistp, PIN_FLD_ARGS, 2, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_TYPE_STR, (void *)type, ebufp); flistp = PIN_FLIST_ELEM_ADD(s_flistp, PIN_FLD_ARGS, 3, ebufp); pdp = PIN_POID_CREATE(database, "/group/plan_list", (int64)-1, ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, (void *)pdp, ebufp); flistp = PIN_FLIST_ELEM_ADD(s_flistp, PIN_FLD_ARGS, 4, ebufp); brand_poidp = cm_fm_perm_get_brand_account(ebufp); if(PIN_POID_IS_NULL(brand_poidp)) { brand_poidp = fm_utils_lineage_root_poid(database, ebufp); } else { if (PIN_POID_GET_ID(brand_poidp) == 1) { brand_poidp = PIN_POID_CREATE(database, PIN_POID_GET_TYPE(brand_poidp), PIN_POID_GET_ID(brand_poidp), ebufp); } else { brand_poidp = PIN_POID_COPY(brand_poidp, ebufp); } } PIN_FLIST_FLD_PUT(flistp, PIN_FLD_ACCOUNT_OBJ, (void *)brand_poidp, ebufp); flistp = PIN_FLIST_ELEM_ADD(s_flistp, PIN_FLD_RESULTS, 0, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_POID, (void *)NULL, ebufp); PIN_FLIST_ELEM_SET(flistp, (pin_flist_t *)NULL, PIN_FLD_MEMBERS, PIN_ELEMID_ANY, ebufp); PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_cust_pol_get_plans search flist", s_flistp); /* * Do the search */ cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); PCM_OP(ctxp, PCM_OP_SEARCH, 0, s_flistp, &r_flistp, ebufp); CM_FM_END_OVERRIDE_SCOPE(cred); /* * We want what is in the result element (assume only one) */ cookie = NULL; *o_flistpp = PIN_FLIST_ELEM_TAKE_NEXT(r_flistp, PIN_FLD_RESULTS, &element_id, 1, &cookie, ebufp); /* * Clean up. */ PIN_FLIST_DESTROY_EX(&s_flistp, NULL); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_get_plans_search error", ebufp); } return; }
/******************************************************************* * fm_cust_pol_get_plans() * * Retrieves the appropriate plan_list object from the db. * Then performs a read_obj of each plan in the list. The * result is an array of available plans for the relevant * aac method (mecca, admin, etc). * *******************************************************************/ static void fm_cust_pol_get_plans( pcm_context_t *ctxp, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *p_flistp = NULL; pin_flist_t *r_flistp = NULL; poid_t *pdp = NULL; int64 brand_db = 0; int64 planlist_db = 0; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /* * Get the database of brand. */ PCM_OP(ctxp, PCM_OP_PERM_GET_CREDENTIALS, 0, i_flistp, &r_flistp, ebufp); pdp = (poid_t *)PIN_FLIST_FLD_GET(r_flistp, PIN_FLD_BRAND_OBJ, 0, ebufp); if ( PIN_POID_GET_ID(pdp) == 1 ) { /* * this has the root brand so * Get the database number of the input PIN_FLD_POID. */ pdp = (poid_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); } brand_db = PIN_POID_GET_DB(pdp); PIN_FLIST_DESTROY_EX( &r_flistp, NULL ); /* * Figure out the database where the plan lists are located. * * The /group/plan_list is the only pricelist object that * does not get replicated in a multidb configuration currently * and resides ONLY in the primary database. */ if (cm_fm_is_multi_db() ) { cm_fm_get_primary_db_no(&planlist_db, ebufp); } else { planlist_db = brand_db; } /* * Locate the desired plan_list */ fm_cust_pol_get_plans_locate(ctxp, planlist_db, i_flistp, &p_flistp, ebufp); /* * Read the plans on the list */ fm_cust_pol_get_plans_retrieve(ctxp, brand_db, i_flistp, p_flistp, o_flistpp, ebufp); /* * Error? */ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_get_plans error", ebufp); } PIN_FLIST_DESTROY_EX(&p_flistp, NULL); return; }
/******************************************************************** * Function : fm_cust_pol_prep_topup * Description : This function will prepare the input flist for the * Standards as well as the Sponsored topup. ********************************************************************/ static void fm_cust_pol_prep_topup( pcm_context_t *ctxp, int32 flags, pin_flist_t *i_flistp, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { int createonly = 0; int status = 0; int index = 0; int sponsore_topup = 0; void *vp = NULL; pin_flist_t *intopup_flistp = NULL; pin_flist_t *outtopup_flistp = NULL; pin_flist_t *ingrptopupmem_flistp = NULL; pin_flist_t *outgrptopupmem_flistp = NULL; pin_flist_t *grptopup_flistp = NULL; pin_flist_t *ingrptopup_flistp = NULL; pin_flist_t *outgrptopup_flistp = NULL; pin_flist_t *r_flistp = NULL; poid_t *intopup_pdp = NULL; poid_t *inparent_pdp = NULL; poid_t *initiator_pdp = NULL; poid_t *grp_pdp = NULL; poid_t *tmp_pdp = NULL; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /**************************************************************** * Get the PIN_FLD_TOPUP_INFO from the input flist. * Value available in the input flist this function construct the * output flist. *****************************************************************/ intopup_flistp = PIN_FLIST_ELEM_GET(i_flistp, PIN_FLD_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); /**************************************************************** * Just copy the input flist to the retflist.If any change is required * for the flist we will manipulate the output flist. ****************************************************************/ *r_flistpp = PIN_FLIST_COPY(i_flistp, ebufp); /**************************************************************** * First check requires the POID and PARENT poid from the input * flist. From this we check whether the call is to * create the standard topup or the sponsored topup. ****************************************************************/ intopup_pdp = (poid_t *)PIN_FLIST_FLD_GET(intopup_flistp, PIN_FLD_POID, 0, ebufp); inparent_pdp = (poid_t *)PIN_FLIST_FLD_GET(intopup_flistp, PIN_FLD_PARENT, 1, ebufp); /**************************************************************** * check the topup poid is just type only or not. ****************************************************************/ if( PIN_POID_IS_TYPE_ONLY(intopup_pdp) ) { /**************************************************************** * topup poid is just type only i,e. 0.0.0.x /topup -1 1 ****************************************************************/ if( PIN_POID_IS_NULL(inparent_pdp) ) { fm_cust_pol_prep_create_standard_topup(ctxp, flags, i_flistp, r_flistpp, ebufp); return; } else { createonly = 1; sponsore_topup = 1; fm_cust_pol_prep_create_sponsored_topup(ctxp, flags, i_flistp, r_flistpp, ebufp); } } else { /**************************************************************** * The input flist contains the valid topup poid. ****************************************************************/ /**************************************************************** * Now read PIN_FLD_GROUP_OBJ and PIN_FLD_GROUP_INDEX from * the /topup object ****************************************************************/ grptopup_flistp = PIN_FLIST_CREATE(ebufp); tmp_pdp = PIN_POID_COPY( intopup_pdp, ebufp); PIN_FLIST_FLD_PUT(grptopup_flistp, PIN_FLD_POID, tmp_pdp, ebufp); /**************************************************************** * setting the group dummy group poid and group index ****************************************************************/ PIN_FLIST_FLD_SET(grptopup_flistp, PIN_FLD_GROUP_OBJ, tmp_pdp, ebufp); PIN_FLIST_FLD_SET(grptopup_flistp, PIN_FLD_GROUP_INDEX, (void *) &index, ebufp); PCM_OP(ctxp, PCM_OP_READ_FLDS, flags, grptopup_flistp, &r_flistp, ebufp); /**************************************************************** * Now get the group object from the return flist. ****************************************************************/ grp_pdp = (poid_t *)PIN_FLIST_FLD_GET(r_flistp, PIN_FLD_GROUP_OBJ, 1, ebufp); /**************************************************************** * check whethere the poid is null or not. ****************************************************************/ if( PIN_POID_IS_NULL(grp_pdp) ) { if( PIN_POID_IS_NULL(inparent_pdp) ) { /**************************************************************** * Since the input flist does not contains the PARENT and * specefied the topup object does not have the GROUP_OBJ * it hase to prepare the flist for the modification * standard topup. ****************************************************************/ fm_cust_pol_prep_modify_standard_topup(ctxp, flags, i_flistp, r_flistpp, ebufp); return ; } else { /**************************************************************** * Input flist have the PARENT poid and the topup object does not have the * valid group poid, hence prepare the flist to create the * sponsored topup. * This case if for a account holder having the standard topup * is being added to PARENts some group. ****************************************************************/ createonly = 1; sponsore_topup = 1; fm_cust_pol_prep_create_sponsored_topup(ctxp, flags, i_flistp, r_flistpp, ebufp); } } else { /**************************************************************** * The topup object is having the valid group poid. * Hence prepare the flistp for modifing the sponsored topup. ****************************************************************/ sponsore_topup = 1; fm_cust_pol_prep_modify_sponsored_topup(ctxp, flags, i_flistp, r_flistpp, ebufp); } PIN_FLIST_DESTROY_EX(&grptopup_flistp, NULL); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); } /**************************************************************** * Check whethere we are preparing the flist for standard or * sponsored topup. Becuse we have to continue exution for * for sponsored topup. ****************************************************************/ if( sponsore_topup ) { initiator_pdp = (poid_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); outtopup_flistp = PIN_FLIST_ELEM_GET(*r_flistpp, PIN_FLD_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); outgrptopup_flistp = PIN_FLIST_ELEM_GET(outtopup_flistp, PIN_FLD_GROUP_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); outgrptopupmem_flistp = PIN_FLIST_ELEM_GET(outgrptopup_flistp, PIN_FLD_GROUP_TOPUP_MEMBERS, PIN_ELEMID_ANY, 0, ebufp); /**************************************************************** * Check who is the intiatore of the operation. ****************************************************************/ if( !PIN_POID_COMPARE( inparent_pdp, initiator_pdp , 0, ebufp) ) { /**************************************************************** * Initiatore is the payers. ****************************************************************/ ingrptopup_flistp = PIN_FLIST_ELEM_GET(intopup_flistp, PIN_FLD_GROUP_TOPUP_INFO, PIN_ELEMID_ANY, 0, ebufp); ingrptopupmem_flistp = PIN_FLIST_ELEM_GET(ingrptopup_flistp, PIN_FLD_GROUP_TOPUP_MEMBERS, PIN_ELEMID_ANY, 0, ebufp); /**************************************************************** * If the STATUS is not set set it to ACTIVE. ****************************************************************/ vp = PIN_FLIST_FLD_GET(ingrptopupmem_flistp, PIN_FLD_STATUS, 1, ebufp); if( vp == NULL ) { status = PIN_STATUS_ACTIVE; PIN_FLIST_FLD_SET(outgrptopupmem_flistp, PIN_FLD_STATUS, &status, ebufp); } /**************************************************************** * If the opcode is creating the sponsored topup and the group * name is not set it to default. ****************************************************************/ if( createonly ) { vp = PIN_FLIST_FLD_GET(ingrptopup_flistp, PIN_FLD_NAME, 1, ebufp); if( vp == NULL ) { PIN_FLIST_FLD_SET(outgrptopup_flistp, PIN_FLD_NAME, (void *)"default", ebufp); } } } else { /**************************************************************** * Initiatore is member account. Set the PIN to NULL and * STATUS is INACTIVE. ****************************************************************/ status = PIN_STATUS_INACTIVE; PIN_FLIST_FLD_SET(outgrptopupmem_flistp, PIN_FLD_STATUS, &status, ebufp); PIN_FLIST_FLD_SET(outgrptopupmem_flistp, PIN_FLD_PIN, (void *)"", ebufp); } } if (PIN_ERR_IS_ERR(ebufp)) PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_prep_topup error", ebufp); return; }
/******************************************************************* * fm_pymt_pol_collect_result_pass(): * * Create the collect result for a PASS pin result. * *******************************************************************/ static void fm_pymt_pol_collect_result_pass( pcm_context_t *ctxp, pin_flist_t *i_flistp, pin_flist_t *r_flistp, pin_errbuf_t *ebufp) { pin_flist_t *b_flistp = NULL; pin_charge_cmd_t *cmd; pin_decimal_t *amount = NULL; pin_decimal_t *pend = NULL; pin_decimal_t *dp = NULL; /*temp*/ char *descr; pin_status_t *status; int *flags; int result; pin_flist_t *vp; pin_flist_t *inh_flistp; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * All passes get the PASS result. ***********************************************************/ result = PIN_RESULT_PASS; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_RESULT, (void *)&result, ebufp); /*********************************************************** * The rest depends on the command. ***********************************************************/ cmd = (pin_charge_cmd_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_COMMAND, 0, ebufp); if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_collect_result_pass error - no command in input flist", ebufp); return; } /*********************************************************** * Calc and add the description. ***********************************************************/ switch (*cmd) { case PIN_CHARGE_CMD_AUTH_ONLY: descr = "authorization successful"; break; case PIN_CHARGE_CMD_CONDITION: descr = "authorization & deposit successful"; break; case PIN_CHARGE_CMD_DEPOSIT: descr = "deposit successful"; break; case PIN_CHARGE_CMD_REFUND: descr = "refund successful"; break; default: /* error - I think */ pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_VALUE, PIN_FLD_COMMAND, 0, *cmd); goto cleanup; } PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_DESCR, (void *)descr, ebufp); vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_AMOUNT, 0, ebufp); if(vp){ inh_flistp = PIN_FLIST_SUBSTR_ADD(r_flistp, PIN_FLD_INHERITED_INFO, ebufp); PIN_FLIST_FLD_SET(inh_flistp, PIN_FLD_AMOUNT, vp, ebufp); } /*********************************************************** * Read the config info. ***********************************************************/ fm_pymt_pol_collect_config(ctxp, i_flistp, &b_flistp, ebufp); /*********************************************************** * Add any needed actions. ***********************************************************/ switch (*cmd) { case PIN_CHARGE_CMD_AUTH_ONLY: case PIN_CHARGE_CMD_CONDITION: case PIN_CHARGE_CMD_REFUND: amount = (pin_decimal_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_AMOUNT, 0, ebufp); pend = (pin_decimal_t *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_PENDING_RECV, 0, ebufp); status = (pin_status_t *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_STATUS, 0, ebufp); flags = (int *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_STATUS_FLAGS, 0, ebufp); if (PIN_ERR_IS_ERR(ebufp)) break; if (pbo_decimal_compare(amount, pend, ebufp) >= 0) { dp = pbo_decimal_negate(pend, ebufp); fm_pymt_pol_collect_clear_pending(r_flistp, dp, "credit toward outstanding bill", ebufp); if ((status && (*status == PIN_STATUS_INACTIVE)) && (flags && (*flags & PIN_STATUS_FLAG_DEBT))) { fm_pymt_pol_collect_set_status(r_flistp, PIN_STATUS_ACTIVE, PIN_STATUS_FLAG_DEBT, "cleared outstanding debt", ebufp); } } else { dp = pbo_decimal_negate(amount, ebufp); fm_pymt_pol_collect_clear_pending(r_flistp, dp, "credit toward outstanding bill", ebufp); } pbo_decimal_destroy(&dp); break; case PIN_CHARGE_CMD_DEPOSIT: break; default: /* error - I think */ pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_VALUE, PIN_FLD_COMMAND, 0, *cmd); goto cleanup; } /*********************************************************** * Cleanup ***********************************************************/ cleanup : PIN_FLIST_DESTROY_EX(&b_flistp, NULL); /*********************************************************** * Error? ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_collect_result_pass error", ebufp); } return; }
static void fm_pymt_pol_spec_collect_get_items( pcm_context_t *ctxp, int32 flags, pin_flist_t *i_flistp, pin_flist_t *o_flistp, pin_errbuf_t *ebufp) { pin_flist_t *items_flistp = NULL; pin_flist_t *r_flistp = NULL; pin_flist_t *flistp = NULL; poid_t *s_pdp = NULL; poid_t *bi_pdp = NULL; int32 status = 0; int64 database = 0; int32 sflags = SRCH_DISTINCT; int32 result = PIN_BOOLEAN_FALSE; void *vp = NULL; pin_decimal_t *zero_decimal = pin_decimal("0.0", ebufp); if (PIN_ERR_IS_ERR(ebufp)) { return; } PIN_ERR_CLEAR_ERR(ebufp); /********************************************************* * Get the ACH details. *********************************************************/ fm_pymt_pol_spec_collect_get_ach(ctxp, flags, i_flistp, o_flistp, ebufp); bi_pdp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_BILLINFO_OBJ, 0, ebufp); /********************************************************* * Create the search flist to search in the item objects *********************************************************/ items_flistp = PIN_FLIST_CREATE(ebufp); database = PIN_POID_GET_DB(bi_pdp); s_pdp = PIN_POID_CREATE(database, "/search", -1, ebufp); PIN_FLIST_FLD_PUT(items_flistp, PIN_FLD_POID, (void *)s_pdp, ebufp); PIN_FLIST_FLD_SET(items_flistp, PIN_FLD_TEMPLATE, (void *) "select X from /item where F1 = V1 and ( F2 = V2 or F3 = V3 )" \ " and F4 != V4 order by F5 ", ebufp); PIN_FLIST_FLD_SET(items_flistp, PIN_FLD_FLAGS, (void *)&sflags, ebufp); /********************************************************* * Add the search arguments. *********************************************************/ flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AR_BILLINFO_OBJ, (void *)bi_pdp, ebufp); status = PIN_ITEM_STATUS_PENDING; flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 2, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)&status, ebufp); status = PIN_ITEM_STATUS_OPEN; flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 3, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)&status, ebufp); flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 4, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DUE, (void *)zero_decimal, ebufp); flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_ARGS, 5, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EFFECTIVE_T, (void *)NULL, ebufp); /********************************************************* * Add the results array for the search. *********************************************************/ flistp = PIN_FLIST_ELEM_ADD(items_flistp, PIN_FLD_RESULTS, 0, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_POID,(void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_BILL_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AR_BILL_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ACCOUNT_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DUE,(void *) NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EFFECTIVE_T, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ITEM_TOTAL, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DISPUTED, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_RECVD, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ADJUSTED, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_TRANSFERED, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_CURRENCY, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ITEM_NO, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_BILLINFO_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_AR_BILLINFO_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_SERVICE_OBJ, (void *)NULL, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EVENT_POID_LIST, (void *)NULL, ebufp); /********************************************************** * search ALL Open and Pending items **********************************************************/ PCM_OP(ctxp, PCM_OP_SEARCH, PCM_OPFLG_READ_UNCOMMITTED , items_flistp, &r_flistp,ebufp); if (PIN_FLIST_FLD_COPY(r_flistp, PIN_FLD_RESULTS, o_flistp, PIN_FLD_ITEMS, ebufp) == 1) { result = PIN_BOOLEAN_TRUE; } PIN_FLIST_FLD_SET(o_flistp, PIN_FLD_BOOLEAN, (void *)&result, ebufp); /********************************************************* * Cleanup... *********************************************************/ PIN_FLIST_DESTROY_EX(&items_flistp, NULL); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); PIN_DECIMAL_DESTROY_EX(&zero_decimal); /********************************************************* * Errors..? *********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_spec_collect_get_items error", ebufp); } return; }
/******************************************************************* * fm_pymt_pol_collect_result_hard(): * * Create the collect result for 'hard' pin declines. * * All hard declines are suject to the same rules. * *******************************************************************/ static void fm_pymt_pol_collect_result_hard( pcm_context_t *ctxp, pin_flist_t *i_flistp, pin_flist_t *r_flistp, pin_errbuf_t *ebufp) { pin_flist_t *b_flistp = NULL; int result; char *descr; pin_status_t *status; int *flags; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * All get the FAIL result and default descr. ***********************************************************/ result = PIN_RESULT_FAIL; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_RESULT, (void *)&result, ebufp); descr = "creditcard operation declined"; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_DESCR, (void *)descr, ebufp); /*********************************************************** * Read the config info. ***********************************************************/ fm_pymt_pol_collect_config(ctxp, i_flistp, &b_flistp, ebufp); /*********************************************************** * If not already inactive for debt/closed, suspend. ***********************************************************/ status = (pin_status_t *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_STATUS, 0, ebufp); flags = (int *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_STATUS_FLAGS, 0, ebufp); if (status) { switch (*status) { case PIN_STATUS_INACTIVE: if (flags && (*flags & PIN_STATUS_FLAG_DEBT)) break; /* intentional fall-thru */ case PIN_STATUS_ACTIVE: fm_pymt_pol_collect_set_status(r_flistp, PIN_STATUS_INACTIVE, PIN_STATUS_FLAG_DEBT, "credit card failure", ebufp); break; case PIN_STATUS_CLOSED: break; default: break; } } /*********************************************************** * Someday check for age of debt and close after so long. ***********************************************************/ /*********************************************************** * Cleanup. ***********************************************************/ PIN_FLIST_DESTROY_EX(&b_flistp, NULL); /* Error? - caught/logged by caller */ return; }
/******************************************************************* * Main routine for the PCM_OP_PYMT_POL_SPEC_COLLECT operation. *******************************************************************/ void op_pymt_pol_spec_collect( cm_nap_connection_t *connp, int32 opcode, int32 flags, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; pin_bill_type_t *p_type = NULL; int32 result = PIN_BOOLEAN_FALSE; char *action = NULL; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_PYMT_POL_SPEC_COLLECT) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_pymt_pol_spec_collect opcode error", ebufp); return; } /*********************************************************** * Debug: What we got. ***********************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_pymt_pol_spec_collect input flist", i_flistp); /*********************************************************** * Prep the return flist. ***********************************************************/ r_flistp = PIN_FLIST_CREATE(ebufp); /*********************************************************** * Get the requested action. The following are supported: * - "commit customer" * ***********************************************************/ action = (char *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_ACTION, 0, ebufp); if ((action != (char *)NULL) && (!strcmp(action, "commit customer"))) { p_type = (pin_bill_type_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_PAY_TYPE, 0, ebufp); /*************************************************** * Credit card ***************************************************/ if ((p_type != NULL) && (*p_type == PIN_BILL_TYPE_CC)) { fm_pymt_pol_spec_collect_commit_cust_cc(ctxp, flags, i_flistp, r_flistp, ebufp); /*************************************************** * Direct Debit ***************************************************/ } else if ((p_type != NULL) && (*p_type == PIN_BILL_TYPE_DD)) { fm_pymt_pol_spec_collect_commit_cust_dd(ctxp, flags, i_flistp, r_flistp, ebufp); /*************************************************** * Assume nothing to collect ***************************************************/ } else { result = PIN_BOOLEAN_FALSE; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_BOOLEAN, (void *)&result, ebufp); } } else { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_VALUE, PIN_FLD_ACTION, 0, 0); } /*********************************************************** * Results. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { /*************************************************** * Log something and return nothing. ***************************************************/ PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_pymt_pol_spec_collect error", ebufp); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); *o_flistpp = NULL; } else { /*************************************************** * Point the real return flist to the right thing. ***************************************************/ PIN_ERR_CLEAR_ERR(ebufp); *o_flistpp = r_flistp; /*************************************************** * Debug: What we're sending back. ***************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_pymt_pol_spec_collect return flist", r_flistp); } return; }
/******************************************************************* * fm_pymt_pol_collect_result_soft(): * * Create the collect result for 'soft' pin declines. * * All soft declines are subject to the same rules, but * we may need/want to treat each command differently. * *******************************************************************/ static void fm_pymt_pol_collect_result_soft( pcm_context_t *ctxp, pin_flist_t *i_flistp, pin_flist_t *r_flistp, pin_errbuf_t *ebufp) { pin_flist_t *a_flistp = NULL; pin_flist_t *b_flistp = NULL; pin_flist_t *flistp = NULL; pin_cookie_t cookie = NULL; int result; int rec_id; char *descr = NULL; pin_status_t *status = NULL; int *flags = NULL; poid_t *a_pdp = NULL; poid_t *s_pdp = NULL; poid_t *b_pdp = NULL; void *vp = NULL; char *templatep; int32 srch_flags = SRCH_DISTINCT; int item_status = PIN_ITEM_STATUS_OPEN; pin_decimal_t *item_due = NULL; time_t start_t = 0; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); item_due = pbo_decimal_from_str("0.01", ebufp); /*********************************************************** * All get the FAIL result and default descr. ***********************************************************/ result = PIN_RESULT_FAIL; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_RESULT, (void *)&result, ebufp); descr = "creditcard operation declined"; PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_DESCR, (void *)descr, ebufp); /*********************************************************** * Read the config info. ***********************************************************/ fm_pymt_pol_collect_config(ctxp, i_flistp, &b_flistp, ebufp); /*********************************************************** * If not already inactive for debt/closed, suspend. ***********************************************************/ status = (pin_status_t *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_STATUS, 0, ebufp); flags = (int *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_STATUS_FLAGS, 0, ebufp); a_pdp = (poid_t *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_POID, 0, ebufp); b_pdp = (poid_t *)PIN_FLIST_FLD_GET(b_flistp, PIN_FLD_LAST_BILL_OBJ, 0, ebufp); /*********************************************************** * Nothing to do, if there was no last bill object. ***********************************************************/ if (PIN_POID_IS_NULL(b_pdp)) { PIN_FLIST_DESTROY_EX(&b_flistp, NULL); pbo_decimal_destroy(&item_due); return; } /*********************************************************** * Read the bill object for the start of the billing cycle. ***********************************************************/ vp = (void *)NULL; a_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, (void *)b_pdp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_START_T, vp, ebufp); /*********************************************************** * Read the info from the last bill object. ***********************************************************/ PCM_OP(ctxp, PCM_OP_READ_FLDS, 0, a_flistp, &flistp, ebufp); vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_START_T, 0,ebufp); if (vp) start_t = *((time_t *)vp); PIN_FLIST_DESTROY_EX(&a_flistp, NULL); PIN_FLIST_DESTROY_EX(&flistp, NULL); /*********************************************************** * Allocate the flist for search the item objects. ***********************************************************/ a_flistp = PIN_FLIST_CREATE(ebufp); /************************************************************** * Construct the search poid. **************************************************************/ s_pdp = PIN_POID_CREATE(PIN_POID_GET_DB(a_pdp), "/search/pin", -1, ebufp); PIN_FLIST_FLD_PUT(a_flistp, PIN_FLD_POID, (void *)s_pdp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_FLAGS, &srch_flags, ebufp); /************************************************************** * Specify the search arguments. **************************************************************/ flistp = PIN_FLIST_ELEM_ADD(a_flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_ACCOUNT_OBJ, (void *)a_pdp, ebufp); flistp = PIN_FLIST_ELEM_ADD(a_flistp, PIN_FLD_ARGS, 2, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_STATUS, (void *)&item_status, ebufp); flistp = PIN_FLIST_ELEM_ADD(a_flistp, PIN_FLD_ARGS, 3, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_DUE, (void *)item_due, ebufp); flistp = PIN_FLIST_ELEM_ADD(a_flistp, PIN_FLD_ARGS, 4, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_EFFECTIVE_T, (void *)&start_t, ebufp); templatep = "select X from /item/$1 " " where F1 = V1 " " and F2 = V2 " " and F3 >= V3 " " and F4 <= V4 "; PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_TEMPLATE, (void *)templatep, ebufp); /************************************************************** * Set-up the results array. **************************************************************/ vp = (void *)NULL; flistp = PIN_FLIST_ELEM_ADD(a_flistp, PIN_FLD_RESULTS, 0, ebufp); PIN_FLIST_FLD_SET(flistp, PIN_FLD_POID, vp, ebufp); /************************************************************** * Call the PCM_OP_SEARCH opcode to do the actual search. **************************************************************/ PCM_OP(ctxp, PCM_OP_SEARCH, 0, a_flistp, &flistp, ebufp); PIN_FLIST_DESTROY_EX(&a_flistp, NULL); /************************************************************** * Did we find any items with 30 days due. **************************************************************/ a_flistp = PIN_FLIST_ELEM_GET_NEXT(flistp, PIN_FLD_RESULTS, &rec_id, 1, &cookie, ebufp); if ((a_flistp != (pin_flist_t *)NULL) && (status)) { switch (*status) { case PIN_STATUS_INACTIVE: if (flags && (*flags & PIN_STATUS_FLAG_DEBT)) break; /* intentional fall-thru */ case PIN_STATUS_ACTIVE: fm_pymt_pol_collect_set_status(r_flistp, PIN_STATUS_INACTIVE, PIN_STATUS_FLAG_DEBT, "credit card pastdue", ebufp); break; case PIN_STATUS_CLOSED: break; default: break; } } /*********************************************************** * Someday check for age of debt and close after so long. ***********************************************************/ /*********************************************************** * Cleanup. ***********************************************************/ PIN_FLIST_DESTROY_EX(&b_flistp, NULL); PIN_FLIST_DESTROY_EX(&flistp, NULL); pbo_decimal_destroy(&item_due); /* Error? - caught/logged by caller */ return; }
/******************************************************************* * Main routine for the PCM_OP_GET_METAFIELD operation. *******************************************************************/ void op_get_meta_field( cm_nap_connection_t *connp, u_int opcode, u_int flags, pin_flist_t *in_flistp, pin_flist_t **ret_flistp, pin_errbuf_t *ebufp) { pcm_context_t *ctxp = connp->dm_ctx; pin_flist_t *r_flistp = NULL; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Insanity check. ***********************************************************/ if (opcode != PCM_OP_GET_METAFIELD) { pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_BAD_OPCODE, 0, 0, opcode); PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_get_meta_field opcode error", ebufp); return; } /* Debug - What we got */ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_get_meta_field", in_flistp); /*********************************************************** * Call main function ***********************************************************/ fm_get_meta_field(ctxp, in_flistp, &r_flistp, ebufp); if (PIN_ERR_IS_ERR(ebufp)) { /*************************************************** * Log Error Buuffer and return. ***************************************************/ PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "op_get_meta_field", ebufp); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); *ret_flistp = NULL; } else { *ret_flistp = PIN_FLIST_COPY(r_flistp, ebufp); /*************************************************** * Debug: What we're sending back. ***************************************************/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "op_get_meta_field return flist", r_flistp); } /*** Print Output What We Got ***/ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG,"fm_get_meta_field", r_flistp); return; }
/******************************************************************* * fm_pymt_pol_collect_config(): * * Performs the initial data gathering needed for figuring * out what policy action is needed. We read some info from * the account object and then also read the last bill object * (as pointed to by the account). * *******************************************************************/ static void fm_pymt_pol_collect_config( pcm_context_t *ctxp, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *a_flistp = NULL; pin_flist_t *r_flistp = NULL; poid_t *a_pdp = NULL; poid_t *b_pdp = NULL; void *vp; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Null the results until we have them. ***********************************************************/ *o_flistpp = (pin_flist_t *)NULL; /*********************************************************** * Get the input info. ***********************************************************/ a_pdp = (poid_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); /*********************************************************** * Create the flist for reading the account. ***********************************************************/ a_flistp = PIN_FLIST_CREATE(ebufp); vp = (void *)a_pdp; PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, vp, ebufp); vp = (void *)NULL; PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_STATUS, vp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_STATUS_FLAGS, vp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_PENDING_RECV, vp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_LAST_BILL_OBJ, vp, ebufp); /*********************************************************** * Read the info from the account. ***********************************************************/ PCM_OP(ctxp, PCM_OP_READ_FLDS, 0, a_flistp, o_flistpp, ebufp); /*********************************************************** * Clean up. ***********************************************************/ PIN_FLIST_DESTROY_EX(&a_flistp, NULL); b_pdp = (poid_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_BILLINFO_OBJ, 0, ebufp); /*********************************************************** * Create the flist for reading the billinfo. ***********************************************************/ a_flistp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_POID, b_pdp, ebufp); vp = (void *)NULL; PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_PENDING_RECV, vp, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_LAST_BILL_OBJ, vp, ebufp); PCM_OP(ctxp, PCM_OP_READ_FLDS, 0, a_flistp, &r_flistp, ebufp); vp = PIN_FLIST_FLD_GET(r_flistp, PIN_FLD_PENDING_RECV, 0, ebufp); PIN_FLIST_FLD_SET(*o_flistpp, PIN_FLD_PENDING_RECV, vp, ebufp); vp = PIN_FLIST_FLD_GET(r_flistp, PIN_FLD_LAST_BILL_OBJ, 0, ebufp); PIN_FLIST_FLD_SET(*o_flistpp, PIN_FLD_LAST_BILL_OBJ, vp, ebufp); PIN_FLIST_DESTROY_EX(&a_flistp, NULL); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); /*********************************************************** * Error? ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_collect_config", ebufp); } return; }
/* * Search for a brand name within a brand. */ static void fm_cust_pol_is_brandname_unique_within_brand( pcm_context_t *ctxp, poid_t *poidp, char *namep, pin_flist_t **r_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *flistp = (pin_flist_t *)NULL; pin_flist_t *rlistp = (pin_flist_t *)NULL; pin_flist_t *sublistp; poid_t *search_poidp; int32 int_val; int32 cred; pin_account_type_t brand_type = PIN_ACCOUNT_TYPE_BRAND; pin_cookie_t cookie = (pin_cookie_t)NULL; pin_flist_t *b_flistp = NULL; pin_flist_t *t_flistp = NULL; poid_t *b_pdp = NULL; poid_t *g_pdp = NULL; poid_t *rootp = NULL; int32 elemid = 0; int under_host = PIN_BOOLEAN_FALSE; void *vp = NULL; /* * If there are pending errors, then short circuit immediately */ if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); fm_utils_lineage_get_brand_hierarchy(ctxp, poidp, &b_flistp, ebufp); if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_is_brandname_unique_within_brand() : " "Call to get brand hierarchy failed ", ebufp); PIN_FLIST_DESTROY_EX (&b_flistp, NULL); fm_cust_pol_read_err_return_list(poidp, namep, r_flistpp, ebufp); goto cleanup; } PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "Got brand hierarchy. Return flist :", b_flistp); t_flistp = PIN_FLIST_ELEM_GET_NEXT(b_flistp, PIN_FLD_RESULTS, &elemid, 1, &cookie, ebufp); if (PIN_ERR_IS_ERR(ebufp) || t_flistp == (pin_flist_t *)NULL) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_is_brandname_unique_within_brand() : " "Call to get first brand failed ", ebufp); PIN_FLIST_DESTROY_EX (&b_flistp, NULL); fm_cust_pol_read_err_return_list(poidp, namep, r_flistpp, ebufp); goto cleanup; } /******************************************** * Get the first brand object from hierarchy ********************************************/ b_pdp = PIN_FLIST_FLD_GET(t_flistp, PIN_FLD_BRAND_OBJ, 0, ebufp); /*************************************************************** * During the brand creation, the first brand object from the * the hierarchy is the parent brand. But, for an existing * brand, the first object is self, the next one in hierarchy * is the parent brand. ***************************************************************/ if (!PIN_POID_COMPARE(b_pdp, poidp, 0, ebufp)) { PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "first brand is self"); t_flistp = PIN_FLIST_ELEM_GET_NEXT(b_flistp, PIN_FLD_RESULTS, &elemid, 1, &cookie, ebufp); if (PIN_ERR_IS_ERR(ebufp) || t_flistp == (pin_flist_t *)NULL) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_is_brandname_unique_within_brand() : " "Call to get second brand failed ", ebufp); PIN_FLIST_DESTROY_EX (&b_flistp, NULL); fm_cust_pol_read_err_return_list(poidp, namep, r_flistpp, ebufp); goto cleanup; } /* Get the parent brand object */ b_pdp = PIN_FLIST_FLD_GET(t_flistp, PIN_FLD_BRAND_OBJ, 0, ebufp); } else { PIN_ERR_LOG_MSG(PIN_ERR_LEVEL_DEBUG, "first brand is parent"); } PIN_ERR_LOG_POID(PIN_ERR_LEVEL_DEBUG, "parent brand = ", b_pdp); /*************************************************************** * Check to see if we are creating brand under brandhost ***************************************************************/ rootp = PIN_POID_CREATE(PIN_POID_GET_DB(poidp), "/account", 1, ebufp); if (!PIN_POID_COMPARE(b_pdp, rootp, 0, ebufp)) { under_host = PIN_BOOLEAN_TRUE; /* creating brand under brandhost */ } else { /* creating sub-brand under a brand */ /* get the group_obj_id0 for the parent brand */ cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); g_pdp = fm_utils_lineage_get_billing_group_by_parent(ctxp, b_pdp, ebufp); CM_FM_END_OVERRIDE_SCOPE(cred); if (PIN_ERR_IS_ERR(ebufp) || g_pdp == (poid_t*)NULL) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_is_brandname_unique_within_brand() : " "Call to get parent group failed ", ebufp); PIN_POID_DESTROY(rootp, NULL); PIN_FLIST_DESTROY_EX (&b_flistp, NULL); fm_cust_pol_read_err_return_list(poidp, namep, r_flistpp, ebufp); goto cleanup; } } PIN_POID_DESTROY(rootp, NULL); PIN_FLIST_DESTROY_EX (&b_flistp, NULL); /* * Create search flist to try to figure out if someother brand already * has this name within the parent brand. */ flistp = PIN_FLIST_CREATE(ebufp); search_poidp = PIN_POID_CREATE(PIN_POID_GET_DB(poidp), "/search", -1, ebufp); PIN_FLIST_FLD_PUT(flistp, PIN_FLD_POID, (void *)search_poidp, ebufp); int_val = SRCH_DISTINCT; PIN_FLIST_FLD_SET(flistp, PIN_FLD_FLAGS, (void *)&int_val, ebufp); /*************************************************************** * We need different search templates for checking duplicate * brandnames under the brandhost or another brand. * The brandhost doesnot have an entry in the /group/billing * storable class. The only way we can get the names of the * existing brands under the brandhost is to check the lineage * tag. Arguments 1 to 3 are the same for both search templates, * but arguments 4 & 5 are different. ***************************************************************/ if (under_host == PIN_BOOLEAN_FALSE) { /* creating sub-brands under a brand */ PIN_FLIST_FLD_SET(flistp, PIN_FLD_TEMPLATE, (void *)TEMPLATE_UNIQUE_UNDER_BRAND, ebufp); } else { /* creating brand under brandhost */ PIN_FLIST_FLD_SET(flistp, PIN_FLD_TEMPLATE, (void *)TEMPLATE_UNIQUE_UNDER_BRANDHOST, ebufp); } PIN_FLIST_ELEM_SET(flistp, NULL, PIN_FLD_RESULTS, 0, ebufp); /* * Arg 1 is the type of the account; only interested in brand accounts */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_ACCOUNT_TYPE, (void *)&brand_type, ebufp); /* * Arg 2 is the name of the brand. */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 2, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_NAME, (void *)namep, ebufp); /* * Arg 3 -- POID of account */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 3, ebufp); PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_POID, NULL, ebufp); if (under_host == PIN_BOOLEAN_FALSE) { /* creating sub-brands under a brand */ /* * Arg 4 -- OBJECT_ID of members from /group/billing */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 4, ebufp); sublistp = PIN_FLIST_ELEM_ADD(sublistp, PIN_FLD_MEMBERS, PIN_ELEMID_ANY, ebufp); PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_OBJECT, (void *)NULL, ebufp); /* * Arg 5 -- POID of the group */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 5, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_POID, (void *)g_pdp, ebufp); } else { /* creating brand under brandhost */ /* * Arg 4 -- Parent of the group */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 4, ebufp); PIN_FLIST_FLD_PUT(sublistp, PIN_FLD_PARENT, NULL, ebufp); /* * Arg 5 -- LINEAGE of account */ /* accounts under brandhost have only one ":" in their lineage tag. We want to exclude others. */ vp = (void *)"%:%:%"; sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 5, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_LINEAGE, vp, ebufp); } /* * Arg 6 -- POID of current account */ sublistp = PIN_FLIST_ELEM_ADD(flistp, PIN_FLD_ARGS, 6, ebufp); PIN_FLIST_FLD_SET(sublistp, PIN_FLD_POID, poidp, ebufp); /* * For completeness, dump the input flist if debugging is enabled. */ PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "fm_cust_pol_is_brandname_unique_within_brand search input flist:", flistp); /* * Ready to search! Temporarily suspend search to ensure that * all brands are traversed. */ cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); PCM_OP(ctxp, PCM_OP_GLOBAL_SEARCH, PCM_OPFLG_COUNT_ONLY, flistp, &rlistp, ebufp); CM_FM_END_OVERRIDE_SCOPE(cred); /* * For completeness, dump the results flist if debugging is enabled * and we actually have a results flist. */ if(rlistp != (pin_flist_t *)NULL) { PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "fm_cust_pol_is_brandname_unique_within_brand search output flist:", rlistp); } /* * See if there is a brand out there right now that already has * this name. If so, flag it as an error. */ cookie = (pin_cookie_t)NULL; int_val = 0; PIN_FLIST_ELEM_GET_NEXT(rlistp, PIN_FLD_RESULTS, &int_val, 1, &cookie, ebufp); if(int_val > 0) { *r_flistpp = PIN_FLIST_CREATE(ebufp); PIN_FLIST_FLD_SET(*r_flistpp, PIN_FLD_POID, (void *)poidp, ebufp); fm_cust_pol_valid_add_fail(*r_flistpp, PIN_FLD_NAME, 0, PIN_CUST_VAL_ERR_DUPE, PIN_CUST_DUPE_VALUE_ERR_MSG, (void *)namep, ebufp); pin_set_err(ebufp, PIN_ERRLOC_FM, PIN_ERRCLASS_SYSTEM_DETERMINATE, PIN_ERR_DUPLICATE, PIN_FLD_NAME, 0, 0); } cleanup: /* * Cleanup and return */ PIN_FLIST_DESTROY_EX(&flistp, NULL); PIN_FLIST_DESTROY_EX(&rlistp, NULL); PIN_POID_DESTROY(g_pdp, NULL); }
/******************************************************************* * fm_pymt_pol_collect_writeoff_account(): * This function checks for the event type . * If event type is /event/billing/writeoff_reversal * then it writesoff the account *******************************************************************/ static void fm_pymt_pol_collect_writeoff_account( pcm_context_t *ctxp, pin_flist_t *i_flistp, int flags, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; pin_flist_t *wa_flistp = NULL; pin_flist_t *r_flistp = NULL; char *writeoff_event_type = { "" }; int result_flag = 0; void *vp = NULL; int32 rec_id; pin_cookie_t cookie = NULL; int temp = 0; u_int count = 0; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Check for the event type /event/billing/writeoff_reversal ***********************************************************/ cookie = NULL; while ((flistp = PIN_FLIST_ELEM_GET_NEXT(i_flistp, PIN_FLD_EVENTS, &rec_id, 1, &cookie, ebufp)) != (pin_flist_t *)NULL){ vp = PIN_FLIST_FLD_GET( flistp, PIN_FLD_POID, 0, ebufp); if (vp != NULL) writeoff_event_type = (char *)PIN_POID_GET_TYPE((poid_t *) vp ); if( writeoff_event_type && strcmp( writeoff_event_type, PIN_OBJ_TYPE_EVENT_WRITEOFF_REVERSAL) == 0 ){ count++; break; } } /***************************************** * Bail out if no WOR performed *****************************************/ if( !count ) return; vp = PIN_FLIST_FLD_GET( flistp, PIN_FLD_RESULT, 0, ebufp); if ( vp != NULL ) { result_flag = *(int *)vp; } if( result_flag == PIN_REVERSE_RES_PASS ) { /*********************************************************** * Writeoff the Account by calling PCM_OP_AR_ACCOUNT_WRITEOFF ***********************************************************/ wa_flistp = PIN_FLIST_CREATE(ebufp); vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); PIN_FLIST_FLD_SET(wa_flistp, PIN_FLD_POID, vp, ebufp); vp = PIN_FLIST_FLD_TAKE(i_flistp, PIN_FLD_PROGRAM_NAME, 0, ebufp); PIN_FLIST_FLD_PUT(wa_flistp, PIN_FLD_PROGRAM_NAME, vp, ebufp); /************************************************************* * Add the String ID and String version for the GL *************************************************************/ temp = PIN_WRITEOFF_FOR_AUTO_WRITEOFF_REVERSAL; PIN_FLIST_FLD_SET(wa_flistp, PIN_FLD_STRING_ID, &temp, ebufp); temp = PIN_REASON_CODES_CREDIT_REASONS; PIN_FLIST_FLD_SET(wa_flistp, PIN_FLD_STR_VERSION, &temp, ebufp); PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "fm_pymt_pol_collect_writeoff_account PCM_OP_AR_ACCOUNT_WRITEOFF input flist", wa_flistp); PCM_OP(ctxp, PCM_OP_AR_ACCOUNT_WRITEOFF, flags, wa_flistp, &r_flistp, ebufp); PIN_ERR_LOG_FLIST(PIN_ERR_LEVEL_DEBUG, "fm_pymt_pol_collect_writeoff_account PCM_OP_AR_ACCOUNT_WRITEOFF output flist", r_flistp); if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_collect_writeoff_account", ebufp); } /*********************************************************** * Clean up. ***********************************************************/ PIN_FLIST_DESTROY_EX(&wa_flistp, NULL); PIN_FLIST_DESTROY_EX(&r_flistp, NULL); } if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_pymt_pol_collect_writeoff_account error", ebufp); } return; }
/******************************************************************* * fm_cust_pol_read_plan_deal() * * For the specified deal object, forms a tree. * Implemented as a subroutine since it is called once for each * service, and then once for any account level deals * *******************************************************************/ static void fm_cust_pol_read_plan_deal(pcm_context_t *ctxp, pin_flist_t *s_flistp, int32 is_account_deal, int32 deal_array, pin_errbuf_t *ebufp) { pin_flist_t *flistp = NULL; /* temp flist */ pin_flist_t *d_flistp = NULL; /* dummy flist */ pin_flist_t *rd_flistp = NULL; /* deal flist (read) */ pin_flist_t *p_flistp = NULL; /* product flist */ int elem_id; void *vp = NULL; poid_t *d_pdp = NULL; pin_cookie_t p_cookie = NULL; /*************************************************** * No point doing any work if there isn't a deal ***************************************************/ vp = PIN_FLIST_FLD_GET(s_flistp, PIN_FLD_DEAL_OBJ, 1, ebufp); if (PIN_POID_IS_NULL((poid_t *)vp)) { /* * Don't drop the DEAL_OBJ is this is an account deal, * because even though it is NULL, it breaks admin for good * measure! */ if (!is_account_deal) { PIN_FLIST_FLD_DROP(s_flistp, PIN_FLD_DEAL_OBJ, ebufp); } return; } /*************************************************** * Read the deal object and add it to the plan tree. ***************************************************/ d_flistp = PIN_FLIST_CREATE(ebufp); d_pdp = PIN_POID_COPY((poid_t *)vp, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_POID, vp, ebufp); PCM_OP(ctxp, PCM_OP_READ_OBJ, 0, d_flistp, &rd_flistp, ebufp); PIN_FLIST_DESTROY_EX(&d_flistp, NULL); PIN_FLIST_FLD_DROP(rd_flistp, PIN_FLD_POID, ebufp); PIN_FLIST_FLD_PUT(rd_flistp, PIN_FLD_DEAL_OBJ, (poid_t *)d_pdp, ebufp); /*************************************************** * Walk thru the products array and read the fields * needed from the respective product obj. ***************************************************/ while ((flistp = PIN_FLIST_ELEM_GET_NEXT(rd_flistp, PIN_FLD_PRODUCTS, &elem_id, 1, &p_cookie, ebufp)) != NULL) { d_flistp = PIN_FLIST_CREATE(ebufp); vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_PRODUCT_OBJ, 0, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_POID, vp, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_NAME, NULL, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_DESCR, NULL, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_OWN_MAX, NULL, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_OWN_MIN, NULL, ebufp); PCM_OP(ctxp, PCM_OP_READ_FLDS, 0, d_flistp, &p_flistp, ebufp); PIN_FLIST_FLD_DROP(p_flistp, PIN_FLD_POID, ebufp); PIN_FLIST_CONCAT(flistp, p_flistp, ebufp); PIN_FLIST_DESTROY_EX(&d_flistp, NULL); PIN_FLIST_DESTROY_EX(&p_flistp, NULL); } p_cookie = NULL; while ((flistp = PIN_FLIST_ELEM_GET_NEXT(rd_flistp, PIN_FLD_DISCOUNTS, &elem_id, 1, &p_cookie, ebufp)) != NULL) { d_flistp = PIN_FLIST_CREATE(ebufp); vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_DISCOUNT_OBJ, 0, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_POID, vp, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_NAME, NULL, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_DESCR, NULL, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_OWN_MAX, NULL, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_OWN_MIN, NULL, ebufp); PCM_OP(ctxp, PCM_OP_READ_FLDS, 0, d_flistp, &p_flistp, ebufp); PIN_FLIST_FLD_DROP(p_flistp, PIN_FLD_POID, ebufp); PIN_FLIST_CONCAT(flistp, p_flistp, ebufp); PIN_FLIST_DESTROY_EX(&d_flistp, NULL); PIN_FLIST_DESTROY_EX(&p_flistp, NULL); } /* Decode the encoded dates into unit and offset */ fm_cust_convert_prod_disc_date_details_into_offset_unit(ctxp, PIN_FLD_PRODUCTS, &rd_flistp, ebufp); fm_cust_convert_prod_disc_date_details_into_offset_unit(ctxp, PIN_FLD_DISCOUNTS, &rd_flistp, ebufp); if (deal_array) { PIN_FLIST_FLD_DROP(rd_flistp, PIN_FLD_DEAL_OBJ, ebufp); PIN_FLIST_CONCAT(s_flistp, rd_flistp, ebufp); PIN_FLIST_DESTROY_EX(&rd_flistp, NULL); } else { PIN_FLIST_ELEM_PUT(s_flistp, rd_flistp, PIN_FLD_DEALS, 0, ebufp); } if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_read_plan_deal error", ebufp); } }
/******************************************************************* * fm_cust_pol_read_plan() * * For the specified plan object, forms a tree. * *******************************************************************/ static void fm_cust_pol_read_plan( pcm_context_t *ctxp, pin_flist_t *i_flistp, pin_flist_t **o_flistpp, pin_errbuf_t *ebufp) { pin_flist_t *d_flistp = NULL; pin_flist_t *s_flistp = NULL; /* service flist */ pin_flist_t *rp_flistp = NULL; /* product flist (read) */ pin_cookie_t d_cookie = NULL; pin_cookie_t cookie = NULL; int32 rec_id = 0; int32 d_rec_id = 0; void *vp = NULL; if (PIN_ERR_IS_ERR(ebufp)) { return; } PIN_ERR_CLEAR_ERR(ebufp); /*********************************************************** * Read the plan object. ***********************************************************/ d_flistp = PIN_FLIST_CREATE(ebufp); vp = PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); PIN_FLIST_FLD_SET(d_flistp, PIN_FLD_POID, vp, ebufp); PCM_OP(ctxp, PCM_OP_READ_OBJ, PCM_OPFLG_ORDER_BY_REC_ID, d_flistp, &rp_flistp, ebufp); PIN_FLIST_DESTROY_EX(&d_flistp, NULL); while ((s_flistp = PIN_FLIST_ELEM_GET_NEXT(rp_flistp, PIN_FLD_SERVICES, &rec_id, 1, &d_cookie, ebufp)) != NULL) { vp = PIN_FLIST_FLD_GET(s_flistp, PIN_FLD_DEAL_OBJ, 1, ebufp); if (vp && PIN_POID_IS_NULL(vp)) { cookie = NULL; while ((d_flistp = PIN_FLIST_ELEM_GET_NEXT(s_flistp, PIN_FLD_DEALS, &d_rec_id, 1, &cookie, ebufp)) != NULL) { fm_cust_pol_read_plan_deal(ctxp, d_flistp, 0, 1, ebufp); } } else { fm_cust_pol_read_plan_deal(ctxp, s_flistp, 0, 0, ebufp); } } /************************************************************* * Now deal with account level plans/deals/products (ie those * with no services associated) *************************************************************/ fm_cust_pol_read_plan_deal(ctxp, rp_flistp, 1, 0, ebufp); /*********************************************************** * Errors. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_cust_pol_read_plan error", ebufp); /************************************************** * Since there is an error return a NULL flist and * delete the one we read **************************************************/ *o_flistpp = NULL; PIN_FLIST_DESTROY_EX( &rp_flistp, NULL ); } else { *o_flistpp = rp_flistp; } return; }
/******************************************************************* * fm_act_pol_add_event_bal_impacts(): *******************************************************************/ void fm_act_pol_add_event_bal_impacts( pcm_context_t *ctxp, pin_flist_t *a_flistp, pin_errbuf_t *ebufp) { pin_cookie_t cookie = NULL; pin_flist_t *bi_flistp = NULL; pin_flist_t *flistp = NULL; pin_flist_t *bia_flistp = NULL; poid_t *r_pdp = NULL; void *vp = NULL; int impact_type = 0; int count = 0; int rec_id = 0; pin_decimal_t *dummyp = NULL; if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); dummyp = pbo_decimal_from_str("0.0", ebufp); /*********************************************************** * Set the balance impact type as pre-rated. ***********************************************************/ impact_type = PIN_IMPACT_TYPE_PRERATED; bia_flistp = PIN_FLIST_CREATE(ebufp); /*********************************************************** * Walk the PIN_FLD_TOTALS array in the original event and * add a corresponding balance impact arary for that. ***********************************************************/ while ((flistp = PIN_FLIST_ELEM_GET_NEXT(a_flistp, PIN_FLD_TOTAL, &rec_id, 1, &cookie, ebufp)) != (pin_flist_t *)NULL) { /*************************************************** * Add a new element for this balance impact. ***************************************************/ count = (int)PIN_FLIST_ELEM_COUNT(bia_flistp, PIN_FLD_BAL_IMPACTS, ebufp); bi_flistp = PIN_FLIST_ELEM_ADD(bia_flistp, PIN_FLD_BAL_IMPACTS, count, ebufp); /*************************************************** * Start filling in the standard field values now. ***************************************************/ PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_IMPACT_TYPE, (void *)&impact_type, ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_RESOURCE_ID, (void *)&rec_id, ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_TAX_CODE, (void *)"", ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_RATE_TAG, (void *)"", ebufp); /*************************************************** * Get and Set the account and item object poids. ***************************************************/ vp = PIN_FLIST_FLD_GET(a_flistp, PIN_FLD_ACCOUNT_OBJ, 0, ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_ACCOUNT_OBJ, vp, ebufp); vp = PIN_FLIST_FLD_GET(a_flistp, PIN_FLD_ITEM_OBJ, 1, ebufp); if (vp) { PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_ITEM_OBJ, vp, ebufp); } /*************************************************** * Fill in the dummy rate object poid. ***************************************************/ r_pdp = PIN_POID_CREATE(0, "", 0, ebufp); PIN_FLIST_FLD_PUT(bi_flistp, PIN_FLD_RATE_OBJ, (void *)r_pdp, ebufp); /*************************************************** * set the 0 for quantity, discount and percentage ***************************************************/ PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_DISCOUNT, (void *)dummyp, ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_PERCENT, (void *)dummyp, ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_QUANTITY, (void *)dummyp, ebufp); /*************************************************** * Set the amount deferred to 0.0 ***************************************************/ PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_AMOUNT_DEFERRED, (void *)dummyp, ebufp); /*************************************************** * Get the amount and set in the bal impact. ***************************************************/ vp = PIN_FLIST_FLD_GET(flistp, PIN_FLD_AMOUNT, 0, ebufp); PIN_FLIST_FLD_SET(bi_flistp, PIN_FLD_AMOUNT, vp, ebufp); } PIN_FLIST_CONCAT(a_flistp, bia_flistp, ebufp); PIN_FLIST_DESTROY_EX(&bia_flistp, NULL); pbo_decimal_destroy(&dummyp); /*********************************************************** * Error? ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) { PIN_ERR_LOG_EBUF(PIN_ERR_LEVEL_ERROR, "fm_act_pol_add_event_bal_impacts error", ebufp); } return; }
void fm_cust_pol_valid_login_check_uniquiness_service( pcm_context_t *ctxp, int64 db_no, int msexchange_service_type, pin_flist_t *i_flistp, pin_flist_t *r_flistp, pin_errbuf_t *ebufp) { pin_flist_t *a_flistp = NULL; pin_flist_t *l_flistp = NULL; pin_flist_t *n_flistp = NULL; pin_flist_t *s1_flistp = NULL; pin_flist_t *s2_flistp = NULL; pin_flist_t *flistp = NULL; poid_t *objp = NULL; poid_t *s_pdp = NULL; void *vp = NULL; const char *subtype = NULL; char *login = NULL; int32 result = PIN_CUST_VERIFY_PASSED; int32 elemid = 0; int32 count1 = 0; int32 count2 = 0; int32 search_flag = SRCH_DISTINCT; pin_cookie_t cookie = NULL; pin_cookie_t cookie2 = NULL; int count = 0; int32 cred = 0; /*********************************************************** * Return immediately if there's an error in ebufp. ***********************************************************/ if (PIN_ERR_IS_ERR(ebufp)) return; PIN_ERR_CLEAR_ERR(ebufp); s_pdp = (poid_t *)PIN_FLIST_FLD_GET(i_flistp, PIN_FLD_POID, 0, ebufp); /********************************************************* * Create the search flist ********************************************************/ s1_flistp = PIN_FLIST_CREATE(ebufp); s2_flistp = PIN_FLIST_CREATE(ebufp); objp = PIN_POID_CREATE(db_no, "/search", -1, ebufp); PIN_FLIST_FLD_SET(s1_flistp, PIN_FLD_POID, (void *)objp, ebufp); PIN_FLIST_FLD_PUT(s2_flistp, PIN_FLD_POID, (void *)objp, ebufp); /****************************************************************** * Set the search template. ******************************************************************/ /********************************************************************** * If Service type is /service/msexchange/user or * /service/msexchange/user/firstadmin * search login name in both /service/msexchange/user and * /service/msexchange/user/firstadmin objects **********************************************************************/ if( msexchange_service_type != PIN_MSEXCHANGE_SERVICE_NONE ){ vp = (void*)"select X from /service where " "F1 = V1 AND ( F2 = V2 OR F3 = V3 ) "; } else { vp = (void*)"select X from /service where " " F1 = V1 AND F2 = V2 "; } PIN_FLIST_FLD_SET(s1_flistp, PIN_FLD_TEMPLATE, vp, ebufp); PIN_FLIST_FLD_SET(s2_flistp, PIN_FLD_TEMPLATE, vp, ebufp); PIN_FLIST_FLD_SET(s1_flistp, PIN_FLD_FLAGS, &search_flag, ebufp); PIN_FLIST_FLD_SET(s2_flistp, PIN_FLD_FLAGS, &search_flag, ebufp); /* Add the search criteria. */ login = PIN_FLIST_FLD_GET( i_flistp, PIN_FLD_LOGIN, 1, ebufp ); /* Look for PIN_FLD_LOG = login */ l_flistp = PIN_FLIST_ELEM_ADD(s1_flistp, PIN_FLD_ARGS, 1, ebufp); PIN_FLIST_FLD_SET(l_flistp, PIN_FLD_LOGIN, (void *)login, ebufp); /* Look for PIN_FLD_ALIAS_LIST - PIN_FLD_NAME = login */ n_flistp = PIN_FLIST_ELEM_ADD(s2_flistp, PIN_FLD_ARGS, 1, ebufp); n_flistp = PIN_FLIST_ELEM_ADD(n_flistp, PIN_FLD_ALIAS_LIST, PIN_ELEMID_ANY, ebufp); PIN_FLIST_FLD_SET(n_flistp, PIN_FLD_NAME, (void *)login, ebufp); /********************************************************************** * If service is /service/msexchange/user type, search login name also * in /service/msexchange/user/firstadmin for unique login name and * vice versa. * Add F3 and V3 Parameters in search template with service type **********************************************************************/ if( msexchange_service_type == PIN_MSEXCHANGE_SERVICE_USER || msexchange_service_type == PIN_MSEXCHANGE_SERVICE_FIRSTADMIN ){ a_flistp = PIN_FLIST_ELEM_ADD(s1_flistp, PIN_FLD_ARGS,2, ebufp); objp = PIN_POID_CREATE(db_no, PIN_MSEXCHANGE_SERVICE_TYPE_FIRSTADMIN, (int64)-1, ebufp); PIN_FLIST_FLD_PUT(a_flistp, PIN_FLD_POID, (void *)objp, ebufp); PIN_FLIST_ELEM_SET(s2_flistp, a_flistp, PIN_FLD_ARGS, 2, ebufp); a_flistp = PIN_FLIST_ELEM_ADD(s1_flistp, PIN_FLD_ARGS,3, ebufp); objp = PIN_POID_CREATE(db_no, PIN_MSEXCHANGE_SERVICE_TYPE_USER, (int64)-1, ebufp); PIN_FLIST_FLD_PUT(a_flistp, PIN_FLD_POID, (void *)objp, ebufp); PIN_FLIST_ELEM_SET(s2_flistp, a_flistp, PIN_FLD_ARGS, 3, ebufp); } else { subtype = PIN_POID_GET_TYPE( s_pdp ); a_flistp = PIN_FLIST_ELEM_ADD(s1_flistp, PIN_FLD_ARGS,2, ebufp); objp = PIN_POID_CREATE(db_no, subtype, (int64)-1, ebufp); PIN_FLIST_FLD_PUT(a_flistp, PIN_FLD_POID, (void *)objp, ebufp); PIN_FLIST_ELEM_SET(s2_flistp, a_flistp, PIN_FLD_ARGS, 2, ebufp); } PIN_FLIST_ELEM_PUT(s1_flistp, NULL, PIN_FLD_RESULTS, 0, ebufp); PIN_FLIST_ELEM_PUT(s2_flistp, NULL, PIN_FLD_RESULTS, 0, ebufp); /************************************************************ * we only search if there was a login * otherwise this was all setup for the alias list searches. ************************************************************/ if( login ) { cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); PCM_OP(ctxp, PCM_OP_SEARCH, PCM_OPFLG_COUNT_ONLY, s1_flistp, &a_flistp, ebufp); cookie = NULL; (void) PIN_FLIST_ELEM_GET_NEXT(a_flistp, PIN_FLD_RESULTS, &count1, 0, &cookie, ebufp); PIN_FLIST_DESTROY_EX( &a_flistp, NULL ); PCM_OP(ctxp, PCM_OP_SEARCH, PCM_OPFLG_COUNT_ONLY, s2_flistp, &a_flistp, ebufp); CM_FM_END_OVERRIDE_SCOPE(cred); cookie = NULL; (void) PIN_FLIST_ELEM_GET_NEXT(a_flistp, PIN_FLD_RESULTS, &count2, 0, &cookie, ebufp); PIN_FLIST_DESTROY_EX( &a_flistp, NULL ); if (count1 > 0 || count2 > 0 ) { (void)fm_cust_pol_valid_add_fail(r_flistp, PIN_FLD_LOGIN, (u_int)NULL, PIN_CUST_VAL_ERR_DUPE, PIN_CUST_DUPE_VALUE_ERR_MSG, (void *)login, ebufp); result = PIN_CUST_VERIFY_FAILED; } } /*********************************************************** * Try to validate all of the alias list ***********************************************************/ cookie = NULL; for ( flistp = PIN_FLIST_ELEM_GET_NEXT( i_flistp, PIN_FLD_ALIAS_LIST, &elemid, 0, &cookie, ebufp ); ebufp->pin_err == PIN_ERR_NONE; flistp = PIN_FLIST_ELEM_GET_NEXT( i_flistp, PIN_FLD_ALIAS_LIST, &elemid, 0, &cookie, ebufp ) ) { if ( !flistp ) continue; login = PIN_FLIST_FLD_GET( flistp, PIN_FLD_NAME, 0, ebufp ); /************************************************************** * the search flist is still set up we just need to replace * the login value with an alias value. **************************************************************/ PIN_FLIST_FLD_SET(l_flistp, PIN_FLD_LOGIN, (void *)login, ebufp); PIN_FLIST_FLD_SET(n_flistp, PIN_FLD_NAME, (void *)login, ebufp); cred = CM_FM_BEGIN_OVERRIDE_SCOPE(CM_CRED_SCOPE_OVERRIDE_ROOT); PCM_OP(ctxp, PCM_OP_SEARCH, PCM_OPFLG_COUNT_ONLY, s1_flistp, &a_flistp, ebufp); cookie2 = NULL; (void) PIN_FLIST_ELEM_GET_NEXT(a_flistp, PIN_FLD_RESULTS, &count1, 0, &cookie2, ebufp); PIN_FLIST_DESTROY_EX( &a_flistp, NULL ); PCM_OP(ctxp, PCM_OP_SEARCH, PCM_OPFLG_COUNT_ONLY, s2_flistp, &a_flistp, ebufp); CM_FM_END_OVERRIDE_SCOPE(cred); cookie2 = NULL; (void) PIN_FLIST_ELEM_GET_NEXT(a_flistp, PIN_FLD_RESULTS, &count2, 0, &cookie2, ebufp); PIN_FLIST_DESTROY_EX( &a_flistp, NULL ); if (count1 > 0 || count2 > 0) { pin_fld_num_t field = PIN_FLD_ALIAS_LIST; /*************************************************** * There is a validation error so normalize it to * the input flist ***************************************************/ result = PIN_CUST_VERIFY_FAILED; count = PIN_FLIST_ELEM_COUNT(r_flistp, PIN_FLD_FIELD, ebufp); a_flistp = PIN_FLIST_ELEM_ADD(r_flistp, PIN_FLD_FIELD, count, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_FIELD_NUM, (void *)&field, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_ELEMENT_ID, (void *)&elemid, ebufp); PIN_FLIST_FLD_SET(a_flistp, PIN_FLD_RESULT, (void *)&result, ebufp); (void)fm_cust_pol_valid_add_fail(a_flistp, PIN_FLD_NAME, (u_int)NULL, PIN_CUST_VAL_ERR_DUPE, PIN_CUST_DUPE_VALUE_ERR_MSG, (void *)login, ebufp); a_flistp = NULL; } } if ( ebufp->pin_err == PIN_ERR_NOT_FOUND ) { PIN_ERR_CLEAR_ERR( ebufp ); } if ( result == PIN_CUST_VERIFY_FAILED ) { PIN_FLIST_FLD_SET(r_flistp, PIN_FLD_RESULT, (void *)&result, ebufp); } PIN_FLIST_DESTROY_EX( &s1_flistp, NULL ); PIN_FLIST_DESTROY_EX( &s2_flistp, NULL ); }