// NewInitMessage Gets a new InitMessage struct
175965
func NewInitMessage(clientName string, user string, password string) InitMessage {
	var authToken map[string]interface{}
	if user == "" {
		authToken = map[string]interface{}{
			"scheme": "none",
		}
	} else {
		authToken = map[string]interface{}{
			"scheme":      "basic",
			"principal":   user,
			"credentials": password,
		}
	}

	return InitMessage{
		clientName: clientName,
		authToken:  authToken,
	}
}
521268
func NewMessenger() *Messenger {
	return &Messenger{
		messageQueue: make(chan *message, 1),
		handlers:     make(map[string]messenger.MessageHandler),
		stop:         make(chan struct{}),
	}
}
710737
func (client *Client) NewInit(endpoint, version, accessKeyId, accessKeySecret, serviceCode string, regionID Region) {
	client.Init(endpoint, version, accessKeyId, accessKeySecret)
	client.serviceCode = serviceCode
	client.regionID = regionID
}
349735
func (c *Context) NewMessage() *OutgoingMessage {
	bot := c.Bot()
	msg := &OutgoingMessage{}
	msg.BotID = bot.ID
	msg.FromID = bot.ID
	msg.WebPreview = true
	if c.Chat.ID != 0 {
		msg.ChatID = c.Chat.ID
	} else {
		msg.ChatID = c.User.ID
	}
	msg.ctx = c
	return msg
}
467833
func (p *peer) sendInitMsg() error {
	msg := lnwire.NewInitMessage(
		p.server.globalFeatures.RawFeatureVector,
		p.localFeatures,
	)

	return p.writeMessage(msg)
}
121406
func NewChatMessage(message string, room int, player *player.Player) *ChatMessage {
	player.SetPlayerSummary()
	record := &ChatMessage{
		PlayerID: player.ID,

		Room:    room,
		Message: message,
	}

	return record
}
368467
func NewMessage(addr string, args ...interface{}) *Message {
	return &Message{Address: addr, Arguments: args}
}
307903
func NewMessage(data []byte) (*Message, error) {
	message := &Message{}
	message.startByte = data[0]
	if len(data) <= 1 {
		return message, nil
	}
	message.Length = data[1]
	message.MessageType = data[2]
	message.Function = ZWaveFunction(data[3])

	var err error
	switch message.Function {
	case ApplicationCommandHandler:
		message.NodeID = data[5]

		message.Data, err = NewApplicationCommandHandler(data[7 : 7+data[6]])
	case DiscoveryNodes:

		message.Data, err = NewDiscoverdNodes(data[7 : 7+data[6]])
	case GetNodeProtocolInfo:

		message.Data, err = NewGetNodeProtocolInfo(data[4:])
	default:
		err = fmt.Errorf("Dropping message function='%s' with data %x (not implemented)", message.Function, data[4:])
	}

	if err != nil {
		return nil, err
	}

	logrus.Debugf("Message: %+v Message data: %+v", message, message.Data)
	return message, err

	// 1 FrameHeader (type of message)
	// 1 Message length
	// 1 Request (00) or Response (01)
	// 1 Function
	//
	// 1 (Node ID)
	// 1 (Command - length)
	// - (Command)
	// - (Transmit options)
	// - (Callback id)
	// 1 Checksum

	// Type
	//Request = 0x00,
	//Response = 0x01,
	//GetVersion = 0x15,
	//MemoryGetId = 0x20,
	//ClockSet = 0x30

	// Transmit options
	//Ack = 0x01,
	//LowPower = 0x02,
	//AutoRoute = 0x04,
	//ForceRoute = 0x08

}
1011679
func NewMessageDialog(parent *Window, flag DialogFlags, t MessageType, buttons ButtonsType, format string, args ...interface{}) *MessageDialog {
	ptr := C.CString(strings.Replace(fmt.Sprintf(format, args...), "%", "%%", -1))
	defer cfree(ptr)
	return &MessageDialog{Dialog{Window{Bin{Container{Widget{
		C._gtk_message_dialog_new(
			ToNative(parent),
			C.GtkDialogFlags(flag),
			C.GtkMessageType(t),
			C.GtkButtonsType(buttons),
			gstring(ptr))}}}}}}
}
895951
func (m *InMessage) Init(r io.Reader) (err error) {
	n, err := r.Read(m.storage[:])
	if err != nil {
		return
	}

	// Make sure the message is long enough.
	const headerSize = unsafe.Sizeof(fusekernel.InHeader{})
	if uintptr(n) < headerSize {
		err = fmt.Errorf("Unexpectedly read only %d bytes.", n)
		return
	}

	m.remaining = m.storage[headerSize:n]

	// Check the header's length.
	if int(m.Header().Len) != n {
		err = fmt.Errorf(
			"Header says %d bytes, but we read %d",
			m.Header().Len,
			n)

		return
	}

	return
}
539682
func NewMessageAction(label, text string) *MessageAction {
	return &MessageAction{
		Label: label,
		Text:  text,
	}
}
1125730
func NewInitMessage(connFeatures *lnwire.RawFeatureVector,
	chainHash chainhash.Hash) *Init {

	return &Init{
		ConnFeatures: connFeatures,
		ChainHash:    chainHash,
	}
}
225227
func NewMessage(command, family, flags int) (*Message, error) {
	nlm := C.nlmsg_alloc()
	if nlm == nil {
		return nil, errors.New("failed to create netlink message")
	}
	C.genlmsg_put(nlm, C.NL_AUTO_PID, C.NL_AUTO_SEQ, C.int(family), 0, C.int(flags), C.uint8_t(command), genlVersion)
	return &Message{nlm: nlm}, nil
}
1030907
func (fw *Framework) NewRequestFromMessage(version string, msg *Message) (req protocol.Request, err error) {
	if !(msg.Type() == "request" || msg.Type() == "direct_request") {
		err = fmt.Errorf("Cannot use `%s` message to construct a Request", msg.Type())
		return
	}

	req, err = fw.NewRequest(version, msg.Agent, msg.SenderID, msg.CallerID, msg.TTL, msg.RequestID, msg.Collective())
	if err != nil {
		return req, fmt.Errorf("Could not create a Request from a Message: %s", err)
	}

	req.SetMessage(msg.Payload)

	if msg.Filter == nil || msg.Filter.Empty() {
		req.NewFilter()
	} else {
		req.SetFilter(msg.Filter)
	}

	return
}
478988
func (a *adapter) newMessage(text string) *hal.Message {
	return &hal.Message{
		ID:   "local-message",
		User: hal.User{ID: "1", Name: "shell"},
		Room: "shell",
		Text: text,
	}
}
685301
func NewMessage() *Message {
	return &Message{
		payload: lane.NewStack(),
		Reports: lane.NewStack(),
		Opts:    cmap.New(),
	}
}
1320095
func init() {
	validation.Rules.Add(
		"regex:projects/.*",
		"${appid}.cfg",
		func(ctx *validation.Context, configSet, path string, content []byte) error {
			cfg := &notifypb.ProjectConfig{}
			if err := proto.UnmarshalText(string(content), cfg); err != nil {
				ctx.Errorf("invalid ProjectConfig proto message: %s", err)
			} else {
				validateProjectConfig(ctx, cfg)
			}
			return nil
		})

	validation.Rules.Add(
		"regex:projects/.*",
		`regex:${appid}/email-templates/[^/]+\.template`,
		validateEmailTemplateFile)
}